File tree 2 files changed +21
-0
lines changed
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')
10
10
const cmd = ( args , cb ) => dedupe ( args ) . then ( ( ) => cb ( ) ) . catch ( cb )
11
11
12
12
const 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
+
13
19
const dryRun = ( args && args . dryRun ) || npm . flatOptions . dryRun
14
20
const where = npm . prefix
15
21
const arb = new Arborist ( {
Original file line number Diff line number Diff line change 1
1
const { test } = require ( 'tap' )
2
2
const requireInject = require ( 'require-inject' )
3
3
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
+
4
19
test ( 'should remove dupes using Arborist' , ( t ) => {
5
20
const dedupe = requireInject ( '../../lib/dedupe.js' , {
6
21
'../../lib/npm.js' : {
You can’t perform that action at this time.
0 commit comments