Skip to content

Commit

Permalink
feat(nodejs dev deps) filter nodejs dev deps when using npm ls (#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
microsoftly committed Oct 5, 2018
1 parent 72f7ec7 commit 146f015
Show file tree
Hide file tree
Showing 46 changed files with 1,620 additions and 347 deletions.
30 changes: 27 additions & 3 deletions analyzers/nodejs/nodejs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,24 @@ var chaiDirectDep = pkg.Import{
},
}

var npmChaiFixtures = []string{
filepath.Join("testdata", "chai", "installed"),
filepath.Join("testdata", "chai", "installed-lockfile"),
filepath.Join("testdata", "chai", "dev-deps"),
}

func TestAnalyzeWithNpmLs(t *testing.T) {
buildTarget := filepath.Join("testdata", "chai", "installed")
t.Parallel()
for _, fixturePath := range npmChaiFixtures {
t.Run(fixturePath, func(t *testing.T) {
t.Parallel()
testAnalyzeWithNpmLs(t, fixturePath)

})
}
}

func testAnalyzeWithNpmLs(t *testing.T, buildTarget string) {
nodeModule := module.Module{
Name: "test",
Type: pkg.NodeJS,
Expand All @@ -107,7 +122,7 @@ func TestAnalyzeWithNpmLs(t *testing.T) {
assert.NoError(t, err)

analyzer.NPM = MockNPM{
JSONFilename: filepath.Join("testdata", "chai", "npm-ls-json.json"),
JSONFilename: filepath.Join(buildTarget, "npm-ls-json.json"),
}

analysisResults, err := analyzer.Analyze()
Expand All @@ -118,8 +133,17 @@ func TestAnalyzeWithNpmLs(t *testing.T) {
}

func TestUsingNodeModuleFallback(t *testing.T) {
buildTarget := filepath.Join("testdata", "chai", "installed")
t.Parallel()
for _, fixturePath := range npmChaiFixtures {
t.Run(fixturePath, func(t *testing.T) {
t.Parallel()
testUsingNodeModuleFallback(t, fixturePath)

})
}
}

func testUsingNodeModuleFallback(t *testing.T, buildTarget string) {
nodeModule := module.Module{
Name: "test",
Type: pkg.NodeJS,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 146f015

Please sign in to comment.