mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
support outdir in tsconfig.json
This commit is contained in:
@@ -175,6 +175,9 @@ class Require extends CallExpr, Import {
|
||||
|
||||
override Module resolveImportedPath() {
|
||||
moduleInFile(result, load(min(int prio | moduleInFile(_, load(prio)))))
|
||||
or
|
||||
not exists(Module mod | moduleInFile(mod, load(_))) and
|
||||
result = Import.super.resolveImportedPath()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -145,7 +145,11 @@ abstract class PathString extends string {
|
||||
n = 0 and result.getContainer() = root and root = getARootFolder()
|
||||
or
|
||||
exists(Path base | base = resolveUpTo(n - 1, root) |
|
||||
exists(string next | next = getComponent(n - 1) |
|
||||
exists(string next |
|
||||
next = getComponent(n - 1)
|
||||
or
|
||||
next = getOriginalTypeScriptFolder(getComponent(n - 1), base.getContainer())
|
||||
|
|
||||
// handle empty components and the special "." folder
|
||||
(next = "" or next = ".") and
|
||||
result = base
|
||||
@@ -174,6 +178,42 @@ abstract class PathString extends string {
|
||||
Path resolve(Folder root) { result = resolveUpTo(getNumComponent(), root) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the first folder from `path`.
|
||||
*/
|
||||
bindingset[path]
|
||||
private string getRootFolderFromPath(string path) {
|
||||
not exists(path.indexOf("/")) and result = path
|
||||
or
|
||||
result = path.substring(0, path.indexOf("/", 0, 0))
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a folder of TypeScript files that is compiled into JavaScript files in `outdir` relative to a `parent`.
|
||||
*/
|
||||
private string getOriginalTypeScriptFolder(string outdir, Folder parent) {
|
||||
exists(JSONObject tsconfig |
|
||||
tsconfig.getFile().getBaseName() = "tsconfig.json" and
|
||||
tsconfig.isTopLevel() and
|
||||
tsconfig.getFile().getParentContainer() = parent
|
||||
|
|
||||
outdir =
|
||||
tsconfig
|
||||
.getPropValue("compilerOptions")
|
||||
.(JSONObject)
|
||||
.getPropValue("outDir")
|
||||
.(JSONString)
|
||||
.getValue() and
|
||||
result =
|
||||
getRootFolderFromPath(tsconfig
|
||||
.getPropValue("include")
|
||||
.(JSONArray)
|
||||
.getElementValue(_)
|
||||
.(JSONString)
|
||||
.getValue())
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* An expression whose value represents a (relative or absolute) file system path.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user