mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
JavaScript: Teach resolveMainModule to try adding extensions.
This commit is contained in:
@@ -84,10 +84,16 @@ File tryExtensions(Folder dir, string basename, int priority) {
|
||||
File resolveMainModule(PackageJSON pkg, int priority) {
|
||||
if exists(MainModulePath::of(pkg))
|
||||
then
|
||||
exists(Container c | c = MainModulePath::of(pkg).resolve() |
|
||||
result = c and priority = 0
|
||||
exists(PathExpr main | main = MainModulePath::of(pkg) |
|
||||
result = main.resolve() and priority = 0
|
||||
or
|
||||
result = tryExtensions(c, "index", priority)
|
||||
result = tryExtensions(main.resolve(), "index", priority)
|
||||
or
|
||||
not exists(main.resolve()) and
|
||||
not exists(main.getExtension()) and
|
||||
exists(int n | n = main.getNumComponent() |
|
||||
result = tryExtensions(main.resolveUpTo(n-1), main.getComponent(n-1), priority)
|
||||
)
|
||||
)
|
||||
else result = tryExtensions(pkg.getFile().getParentContainer(), "index", priority)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user