diff options
author | isaacs <i@izs.me> | 2021-05-11 01:10:25 +0300 |
---|---|---|
committer | isaacs <i@izs.me> | 2021-05-20 19:35:28 +0300 |
commit | 0d1a9d78779dc015242fc03d2dad2039004fa2df (patch) | |
tree | 73258681bc9df2a7ef16819c8590c32c1dd12603 /test | |
parent | 41099d3958d08f166313b7eb69b76458f8f9224c (diff) |
Add workspaces support to reify/rebuild commands
This adds `--workspace` support to:
- audit (including audit fix)
- ci
- dedupe
- find-dupes
- install
- install-ci-test
- install-test
- prune
- rebuild
- uninstall
- update
Also addresses missing error handling case, identified by @timoxley.
https://github.com/npm/cli/pull/3227#discussion_r631024491
PR-URL: https://github.com/npm/cli/pull/3227
Credit: @isaacs
Close: #3227
Reviewed-by: @ruyadorno
Diffstat (limited to 'test')
-rw-r--r-- | test/lib/update.js | 16 | ||||
-rw-r--r-- | test/lib/workspaces/arborist-cmd.js | 16 |
2 files changed, 29 insertions, 3 deletions
diff --git a/test/lib/update.js b/test/lib/update.js index 5396397d5..411d07592 100644 --- a/test/lib/update.js +++ b/test/lib/update.js @@ -37,7 +37,12 @@ t.test('no args', t => { constructor (args) { t.same( args, - { ...npm.flatOptions, path: npm.prefix, log: noop }, + { + ...npm.flatOptions, + path: npm.prefix, + log: noop, + workspaces: null, + }, 'should call arborist contructor with expected args' ) } @@ -71,7 +76,12 @@ t.test('with args', t => { constructor (args) { t.same( args, - { ...npm.flatOptions, path: npm.prefix, log: noop }, + { + ...npm.flatOptions, + path: npm.prefix, + log: noop, + workspaces: null, + }, 'should call arborist contructor with expected args' ) } @@ -139,7 +149,7 @@ t.test('update --global', t => { const { path, ...opts } = args t.same( opts, - { ...npm.flatOptions, log: noop }, + { ...npm.flatOptions, log: noop, workspaces: undefined }, 'should call arborist contructor with expected options' ) diff --git a/test/lib/workspaces/arborist-cmd.js b/test/lib/workspaces/arborist-cmd.js index cceeb68db..740ddb1ff 100644 --- a/test/lib/workspaces/arborist-cmd.js +++ b/test/lib/workspaces/arborist-cmd.js @@ -107,3 +107,19 @@ t.test('arborist-cmd', async t => { cmd.execWorkspaces([], ['./group'], res) }) }) + +t.test('handle getWorkspaces raising an error', t => { + const ArboristCmd = t.mock('../../../lib/workspaces/arborist-cmd.js', { + '../../../lib/workspaces/get-workspaces.js': async () => { + throw new Error('oopsie') + }, + }) + class TestCmd extends ArboristCmd {} + const cmd = new TestCmd() + cmd.npm = {} + + cmd.execWorkspaces(['foo'], ['a'], er => { + t.match(er, { message: 'oopsie' }) + t.end() + }) +}) |