diff options
-rw-r--r-- | lib/outdated.js | 6 | ||||
-rw-r--r-- | tap-snapshots/test-lib-outdated.js-TAP.test.js | 25 | ||||
-rw-r--r-- | test/lib/outdated.js | 33 |
3 files changed, 64 insertions, 0 deletions
diff --git a/lib/outdated.js b/lib/outdated.js index e7c800dc9..c3b15e411 100644 --- a/lib/outdated.js +++ b/lib/outdated.js @@ -130,6 +130,12 @@ async function outdated_ (tree, deps, opts) { : edge.dev ? 'devDependencies' : 'dependencies' + for (const omitType of opts.omit || []) { + if (node[omitType]) { + return + } + } + // deps different from prod not currently // on disk are not included in the output if (edge.error === 'MISSING' && type !== 'dependencies') return diff --git a/tap-snapshots/test-lib-outdated.js-TAP.test.js b/tap-snapshots/test-lib-outdated.js-TAP.test.js index e2f580b96..7f245b09e 100644 --- a/tap-snapshots/test-lib-outdated.js-TAP.test.js +++ b/tap-snapshots/test-lib-outdated.js-TAP.test.js @@ -91,6 +91,31 @@ gamma 1.0.1 1.0.1 2.0.0 node_modules/gamma outdated-should-display-ou theta MISSING 1.0.1 1.0.1 - outdated-should-display-outdated-deps dependencies ` +exports[`test/lib/outdated.js TAP should display outdated deps outdated --omit=dev --omit=peer > must match snapshot 1`] = ` + +[4mPackage[24m [4mCurrent[24m [4mWanted[24m [4mLatest[24m [4mLocation[24m [4mDepended by[24m +[31malpha[39m 1.0.0 [32m1.0.1[39m [35m1.0.1[39m node_modules/alpha outdated-should-display-outdated-deps +[33mgamma[39m 1.0.1 [32m1.0.1[39m [35m2.0.0[39m node_modules/gamma outdated-should-display-outdated-deps +[31mtheta[39m MISSING [32m1.0.1[39m [35m1.0.1[39m - outdated-should-display-outdated-deps +` + +exports[`test/lib/outdated.js TAP should display outdated deps outdated --omit=dev > must match snapshot 1`] = ` + +[4mPackage[24m [4mCurrent[24m [4mWanted[24m [4mLatest[24m [4mLocation[24m [4mDepended by[24m +[31malpha[39m 1.0.0 [32m1.0.1[39m [35m1.0.1[39m node_modules/alpha outdated-should-display-outdated-deps +[31mbeta[39m 1.0.0 [32m1.0.1[39m [35m1.0.1[39m node_modules/beta outdated-should-display-outdated-deps +[33mgamma[39m 1.0.1 [32m1.0.1[39m [35m2.0.0[39m node_modules/gamma outdated-should-display-outdated-deps +[31mtheta[39m MISSING [32m1.0.1[39m [35m1.0.1[39m - outdated-should-display-outdated-deps +` + +exports[`test/lib/outdated.js TAP should display outdated deps outdated --omit=prod > must match snapshot 1`] = ` + +[4mPackage[24m [4mCurrent[24m [4mWanted[24m [4mLatest[24m [4mLocation[24m [4mDepended by[24m +[31malpha[39m 1.0.0 [32m1.0.1[39m [35m1.0.1[39m node_modules/alpha outdated-should-display-outdated-deps +[31mbeta[39m 1.0.0 [32m1.0.1[39m [35m1.0.1[39m node_modules/beta outdated-should-display-outdated-deps +[33mgamma[39m 1.0.1 [32m1.0.1[39m [35m2.0.0[39m node_modules/gamma outdated-should-display-outdated-deps +` + exports[`test/lib/outdated.js TAP should display outdated deps outdated --parseable --long > must match snapshot 1`] = ` {CWD}/test/lib/outdated-should-display-outdated-deps/node_modules/alpha:alpha@1.0.1:alpha@1.0.0:alpha@1.0.1:outdated-should-display-outdated-deps:dependencies: diff --git a/test/lib/outdated.js b/test/lib/outdated.js index ad61f0413..0cba04d54 100644 --- a/test/lib/outdated.js +++ b/test/lib/outdated.js @@ -194,6 +194,39 @@ t.test('should display outdated deps', t => { }) }) + t.test('outdated --omit=dev', t => { + outdated(testDir, { + global: false, + color: true, + omit: ['dev'] + })([], () => { + t.matchSnapshot(logs) + t.end() + }) + }) + + t.test('outdated --omit=dev --omit=peer', t => { + outdated(testDir, { + global: false, + color: true, + omit: ['dev', 'peer'] + })([], () => { + t.matchSnapshot(logs) + t.end() + }) + }) + + t.test('outdated --omit=prod', t => { + outdated(testDir, { + global: false, + color: true, + omit: ['prod'] + })([], () => { + t.matchSnapshot(logs) + t.end() + }) + }) + t.test('outdated --long', t => { outdated(testDir, { global: false, |