Skip to content

Commit

Permalink
Merge pull request #233 from snyk/fix/snyk-resolve-deps-update
Browse files Browse the repository at this point in the history
Fix/snyk resolve deps update
  • Loading branch information
Kirill89 committed Oct 5, 2018
2 parents 03ccd68 + fa4fa08 commit 29b8dc9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"snyk-policy": "1.12.0",
"snyk-python-plugin": "1.8.1",
"snyk-resolve": "1.0.1",
"snyk-resolve-deps": "4.0.0",
"snyk-resolve-deps": "4.0.1",
"snyk-sbt-plugin": "2.0.0",
"snyk-tree": "^1.0.0",
"snyk-try-require": "1.3.1",
Expand Down
7 changes: 6 additions & 1 deletion src/lib/snyk-test/npm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,12 @@ function generateDependenciesFromLockfile(root, options) {
}

function getDependenciesFromNodeModules(root, options) {
return fs.exists(path.join(root, 'node_modules'))
var nodeModulesPath = path.join(
path.dirname(path.resolve(root, options.file || '')),
'node_modules'
);

return fs.exists(nodeModulesPath)
.then(function (nodeModulesExist) {
if (!nodeModulesExist) {
// throw a custom error
Expand Down
13 changes: 13 additions & 0 deletions test/acceptance/cli.acceptance.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,19 @@ test('`test empty --file=Gemfile`', function (t) {
});
});

test('`test --file=fixtures/protect/package.json`', function (t) {
return cli.test(
path.resolve(__dirname, '..'),
{file: 'fixtures/protect/package.json'}
).then(function (res) {
t.match(
res,
/Tested 1 dependencies for known vulnerabilities/,
'should succeed in a folder',
);
}).catch((err) => t.throws(err, 'should succeed'));
});

test('`test /` test for non-existent with path specified', function (t) {
chdirWorkspaces();
return cli.test('/')
Expand Down

0 comments on commit 29b8dc9

Please sign in to comment.