JavaScript: Handle empty package.json files gracefully.

This commit is contained in:
Max Schaefer
2020-09-25 12:12:39 +01:00
parent 4deb43f361
commit 0ccbaf9e88
5 changed files with 48 additions and 1 deletions

View File

@@ -126,7 +126,11 @@ public class ScriptExtractor implements IExtractor {
}
try {
BufferedReader reader = new BufferedReader(new FileReader(file));
String result = new Gson().fromJson(reader, PackageJSON.class).type;
PackageJSON pkgjson = new Gson().fromJson(reader, PackageJSON.class);
if (pkgjson == null) {
return null;
}
String result = pkgjson.type;
packageTypeCache.put(folder, Optional.ofNullable(result));
return result;
} catch (IOException | JsonSyntaxException e) {