File tree Expand file tree Collapse file tree 3 files changed +11
-13
lines changed Expand file tree Collapse file tree 3 files changed +11
-13
lines changed Original file line number Diff line number Diff line change @@ -96,10 +96,7 @@ class Pkg extends BaseCommand {
96
96
97
97
async set ( args ) {
98
98
const setError = ( ) =>
99
- Object . assign (
100
- new TypeError ( 'npm pkg set expects a key=value pair of args.' ) ,
101
- { code : 'EPKGSET' }
102
- )
99
+ this . usageError ( 'npm pkg set expects a key=value pair of args.' )
103
100
104
101
if ( ! args . length )
105
102
throw setError ( )
@@ -123,10 +120,7 @@ class Pkg extends BaseCommand {
123
120
124
121
async delete ( args ) {
125
122
const setError = ( ) =>
126
- Object . assign (
127
- new TypeError ( 'npm pkg delete expects key args.' ) ,
128
- { code : 'EPKGDELETE' }
129
- )
123
+ this . usageError ( 'npm pkg delete expects key args.' )
130
124
131
125
if ( ! args . length )
132
126
throw setError ( )
Original file line number Diff line number Diff line change @@ -4,6 +4,10 @@ const formatDiff = require('./lib/format-diff.js')
4
4
const getTarball = require ( './lib/tarball.js' )
5
5
const untar = require ( './lib/untar.js' )
6
6
7
+ // TODO: we test this condition in the diff command
8
+ // so this error probably doesnt need to be here. Or
9
+ // if it does we should figure out a standard code
10
+ // so we can catch it in the cli and display it consistently
7
11
const argsError = ( ) =>
8
12
Object . assign (
9
13
new TypeError ( 'libnpmdiff needs two arguments to compare' ) ,
Original file line number Diff line number Diff line change @@ -196,7 +196,7 @@ t.test('set no args', async t => {
196
196
} )
197
197
await t . rejects (
198
198
pkg . exec ( [ 'set' ] ) ,
199
- { code : 'EPKGSET ' } ,
199
+ { code : 'EUSAGE ' } ,
200
200
'should throw an error if no args'
201
201
)
202
202
} )
@@ -207,7 +207,7 @@ t.test('set missing value', async t => {
207
207
} )
208
208
await t . rejects (
209
209
pkg . exec ( [ 'set' , 'key=' ] ) ,
210
- { code : 'EPKGSET ' } ,
210
+ { code : 'EUSAGE ' } ,
211
211
'should throw an error if missing value'
212
212
)
213
213
} )
@@ -218,7 +218,7 @@ t.test('set missing key', async t => {
218
218
} )
219
219
await t . rejects (
220
220
pkg . exec ( [ 'set' , '=value' ] ) ,
221
- { code : 'EPKGSET ' } ,
221
+ { code : 'EUSAGE ' } ,
222
222
'should throw an error if missing key'
223
223
)
224
224
} )
@@ -424,7 +424,7 @@ t.test('delete no args', async t => {
424
424
} )
425
425
await t . rejects (
426
426
pkg . exec ( [ 'delete' ] ) ,
427
- { code : 'EPKGDELETE ' } ,
427
+ { code : 'EUSAGE ' } ,
428
428
'should throw an error if deleting no args'
429
429
)
430
430
} )
@@ -435,7 +435,7 @@ t.test('delete invalid key', async t => {
435
435
} )
436
436
await t . rejects (
437
437
pkg . exec ( [ 'delete' , '' ] ) ,
438
- { code : 'EPKGDELETE ' } ,
438
+ { code : 'EUSAGE ' } ,
439
439
'should throw an error if deleting invalid args'
440
440
)
441
441
} )
You can’t perform that action at this time.
0 commit comments