File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,12 @@ const completion = require('./utils/completion/none.js')
1010const cmd = ( args , cb ) => dedupe ( args ) . then ( ( ) => cb ( ) ) . catch ( cb )
1111
1212const dedupe = async ( args ) => {
13+ if ( npm . flatOptions . global ) {
14+ const er = new Error ( '`npm dedupe` does not work in global mode.' )
15+ er . code = 'EDEDUPEGLOBAL'
16+ throw er
17+ }
18+
1319 const dryRun = ( args && args . dryRun ) || npm . flatOptions . dryRun
1420 const where = npm . prefix
1521 const arb = new Arborist ( {
Original file line number Diff line number Diff line change 11const { test } = require ( 'tap' )
22const requireInject = require ( 'require-inject' )
33
4+ test ( 'should throw in global mode' , ( t ) => {
5+ const dedupe = requireInject ( '../../lib/dedupe.js' , {
6+ '../../lib/npm.js' : {
7+ flatOptions : {
8+ global : true ,
9+ } ,
10+ } ,
11+ } )
12+
13+ dedupe ( [ ] , er => {
14+ t . match ( er , { code : 'EDEDUPEGLOBAL' } , 'throws EDEDUPEGLOBAL' )
15+ t . end ( )
16+ } )
17+ } )
18+
419test ( 'should remove dupes using Arborist' , ( t ) => {
520 const dedupe = requireInject ( '../../lib/dedupe.js' , {
621 '../../lib/npm.js' : {
You can’t perform that action at this time.
0 commit comments