Skip to content

Commit 1f64722

Browse files
committed
TS: Move definition of mainStr
1 parent 9ed7758 commit 1f64722

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -801,15 +801,6 @@ private Path guessPackageMainFile(Path packageJsonFile, JsonObject packageJson,
801801
return resolved;
802802
}
803803

804-
// Get the "main" property from the package.json
805-
// This usually refers to the compiled output, such as `./out/foo.js` but may hint as to
806-
// the name of main file ("foo" in this case).
807-
String mainStr = null;
808-
JsonElement mainElm = packageJson.get("main");
809-
if (mainElm instanceof JsonPrimitive && ((JsonPrimitive)mainElm).isString()) {
810-
mainStr = mainElm.getAsString();
811-
}
812-
813804
// Look for source files `./src` if it exists
814805
Path sourceDir = packageDir.resolve("src");
815806
if (Files.isDirectory(sourceDir)) {
@@ -819,6 +810,11 @@ private Path guessPackageMainFile(Path packageJsonFile, JsonObject packageJson,
819810
return resolved;
820811
}
821812

813+
// Get the "main" property from the package.json
814+
// This usually refers to the compiled output, such as `./out/foo.js` but may hint as to
815+
// the name of main file ("foo" in this case).
816+
String mainStr = getChildAsString(packageJson, "main");
817+
822818
// If "main" was defined, try to map it to a file in `src`.
823819
// For example `out/dist/foo.bundle.js` might be mapped back to `src/foo.ts`.
824820
if (mainStr != null) {

0 commit comments

Comments
 (0)