Skip to content

Commit

Permalink
fix: Change strictOutOfSync to always be a string
Browse files Browse the repository at this point in the history
  • Loading branch information
lili2311 committed Mar 12, 2019
1 parent e9679de commit b7a5b42
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/lib/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ interface Options {
docker?: boolean;
traverseNodeModules?: boolean;
dev?: boolean;
strictOutOfSync?: boolean;
strictOutOfSync?: boolean | 'true' | 'false';
}

interface Plugin {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/plugins/npm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as snyk from '../../';
interface Options {
traverseNodeModules?: boolean;
dev?: boolean;
strictOutOfSync?: boolean;
strictOutOfSync?: boolean | 'true' | 'false';
}

interface InspectResult {
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/lib/plugins/yarn/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const debug = Debug('snyk');
interface Options {
traverseNodeModules?: boolean;
dev?: boolean;
strictOutOfSync?: boolean;
strictOutOfSync?: boolean | 'true' | 'false';
}

interface InspectResult {
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions src/lib/snyk-test/npm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions test/acceptance/cli.acceptance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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');
Expand Down

0 comments on commit b7a5b42

Please sign in to comment.