mirror of
https://github.com/github/codeql.git
synced 2026-01-07 19:50:22 +01:00
JavaScript: Teach autobuilder not to extract node_modules and bower_components folders.
This commit is contained in:
@@ -387,6 +387,10 @@ public class AutoBuild {
|
||||
patterns.add("-**/*.min.js");
|
||||
patterns.add("-**/*-min.js");
|
||||
|
||||
// exclude `node_modules` and `bower_components`
|
||||
patterns.add("-**/node_modules");
|
||||
patterns.add("-**/bower_components");
|
||||
|
||||
String base = LGTM_SRC.toString().replace('\\', '/');
|
||||
// process `$LGTM_INDEX_FILTERS`
|
||||
for (String pattern : Main.NEWLINE.split(getEnvVar("LGTM_INDEX_FILTERS", ""))) {
|
||||
|
||||
@@ -483,6 +483,40 @@ public class AutoBuildTests {
|
||||
runTest();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nodeModulesAreExcluded() throws IOException {
|
||||
addFile(true, LGTM_SRC, "index.js");
|
||||
addFile(false, LGTM_SRC, "node_modules", "dep", "main.js");
|
||||
addFile(false, LGTM_SRC, "node_modules", "dep", "node_modules", "leftpad", "index.js");
|
||||
runTest();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nodeModulesCanBeReincluded() throws IOException {
|
||||
envVars.put("LGTM_INDEX_FILTERS", "include:**/node_modules");
|
||||
addFile(true, LGTM_SRC, "index.js");
|
||||
addFile(true, LGTM_SRC, "node_modules", "dep", "main.js");
|
||||
addFile(true, LGTM_SRC, "node_modules", "dep", "node_modules", "leftpad", "index.js");
|
||||
runTest();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bowerComponentsAreExcluded() throws IOException {
|
||||
addFile(true, LGTM_SRC, "index.js");
|
||||
addFile(false, LGTM_SRC, "bower_components", "dep", "main.js");
|
||||
addFile(false, LGTM_SRC, "bower_components", "dep", "bower_components", "leftpad", "index.js");
|
||||
runTest();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bowerComponentsCanBeReincluded() throws IOException {
|
||||
envVars.put("LGTM_INDEX_FILTERS", "include:**/bower_components");
|
||||
addFile(true, LGTM_SRC, "index.js");
|
||||
addFile(true, LGTM_SRC, "bower_components", "dep", "main.js");
|
||||
addFile(true, LGTM_SRC, "bower_components", "dep", "bower_components", "leftpad", "index.js");
|
||||
runTest();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customExtensions() throws IOException {
|
||||
envVars.put("LGTM_INDEX_FILETYPES", ".jsm:js\n.soy:html");
|
||||
|
||||
Reference in New Issue
Block a user