diff --git a/src/lib/plugins/index.ts b/src/lib/plugins/index.ts index 02d9b104de..9c090c7ab2 100644 --- a/src/lib/plugins/index.ts +++ b/src/lib/plugins/index.ts @@ -22,7 +22,7 @@ interface Options { docker?: boolean; traverseNodeModules?: boolean; dev?: boolean; - strictOutOfSync?: boolean; + strictOutOfSync?: boolean | 'true' | 'false'; } interface Plugin { diff --git a/src/lib/plugins/npm/index.ts b/src/lib/plugins/npm/index.ts index 19cb696e85..07c5cdc7a1 100644 --- a/src/lib/plugins/npm/index.ts +++ b/src/lib/plugins/npm/index.ts @@ -7,7 +7,7 @@ import * as snyk from '../../'; interface Options { traverseNodeModules?: boolean; dev?: boolean; - strictOutOfSync?: boolean; + strictOutOfSync?: boolean | 'true' | 'false'; } interface InspectResult { @@ -67,7 +67,7 @@ async function generateDependenciesFromLockfile(root: string, targetFile: string ]); const defaultManifestFileName = path.relative(root, manifestFileFullPath); - const strictOutOfSync = _.get(options, 'strictOutOfSync', true); + const strictOutOfSync = _.get(options, 'strictOutOfSync') !== 'false'; return await buildDepTree( manifestFile, diff --git a/src/lib/plugins/yarn/index.ts b/src/lib/plugins/yarn/index.ts index 58f0505791..ef3b5f55b9 100644 --- a/src/lib/plugins/yarn/index.ts +++ b/src/lib/plugins/yarn/index.ts @@ -10,7 +10,7 @@ const debug = Debug('snyk'); interface Options { traverseNodeModules?: boolean; dev?: boolean; - strictOutOfSync?: boolean; + strictOutOfSync?: boolean | 'true' | 'false'; } interface InspectResult { @@ -85,7 +85,7 @@ async function generateDependenciesFromLockfile(root, options, targetFile): Prom ]); const defaultManifestFileName = path.relative(root, manifestFileFullPath); - const strictOutOfSync = _.get(options, 'strictOutOfSync', true); + const strictOutOfSync = _.get(options, 'strictOutOfSync') !== 'false'; return buildDepTree( manifestFile, diff --git a/src/lib/snyk-test/npm/index.js b/src/lib/snyk-test/npm/index.js index aeb904b42d..f24d982235 100644 --- a/src/lib/snyk-test/npm/index.js +++ b/src/lib/snyk-test/npm/index.js @@ -149,8 +149,10 @@ function generateDependenciesFromLockfile(root, options, targetFile) { debug(resolveModuleSpinnerLabel); return spinner(resolveModuleSpinnerLabel) .then(() => { - const strictOutOfSync = _.get(options, 'strictOutOfSync', true); - return lockFileParser.buildDepTree(manifestFile, lockFile, options.dev, lockFileType, strictOutOfSync); + const strictOutOfSync = _.get(options, 'strictOutOfSync') !== 'false'; + + return lockFileParser + .buildDepTree(manifestFile, lockFile, options.dev, lockFileType, strictOutOfSync); }) // clear spinner in case of success or failure .then(spinner.clear(resolveModuleSpinnerLabel)) diff --git a/test/acceptance/cli.acceptance.test.ts b/test/acceptance/cli.acceptance.test.ts index 24f36c1b6e..f7123c9630 100644 --- a/test/acceptance/cli.acceptance.test.ts +++ b/test/acceptance/cli.acceptance.test.ts @@ -867,7 +867,7 @@ if (getRuntimeVersion() > 4) { test('`test yarn-out-of-sync --strictOutOfSync=false` passes', async (t) => { chdirWorkspaces(); - await cli.test('yarn-out-of-sync', { dev: true, strictOutOfSync: false}); + await cli.test('yarn-out-of-sync', { dev: true, strictOutOfSync: 'false'}); const req = server.popRequest(); const pkg = req.body; t.equal(req.method, 'POST', 'makes POST request'); @@ -881,7 +881,7 @@ if (getRuntimeVersion() > 4) { test('`test npm-out-of-sync --strictOutOfSync=false` passes', async (t) => { chdirWorkspaces(); - await cli.test('npm-out-of-sync', { dev: true, strictOutOfSync: false}); + await cli.test('npm-out-of-sync', { dev: true, strictOutOfSync: 'false' }); const req = server.popRequest(); const pkg = req.body; t.equal(req.method, 'POST', 'makes POST request');