@@ -5,7 +5,7 @@ const pacote = require('pacote')
5
5
const path = require ( 'path' )
6
6
const rimraf = promisify ( require ( 'rimraf' ) )
7
7
const semver = require ( 'semver' )
8
- const BaseCommand = require ( './base-command.js' )
8
+ const BaseCommand = require ( '.. /base-command.js' )
9
9
const npa = require ( 'npm-package-arg' )
10
10
const jsonParse = require ( 'json-parse-even-better-errors' )
11
11
const localeCompare = require ( '@isaacs/string-locale-compare' ) ( 'en' )
@@ -104,11 +104,7 @@ class Cache extends BaseCommand {
104
104
}
105
105
}
106
106
107
- exec ( args , cb ) {
108
- this . cache ( args ) . then ( ( ) => cb ( ) ) . catch ( cb )
109
- }
110
-
111
- async cache ( args ) {
107
+ async exec ( args ) {
112
108
const cmd = args . shift ( )
113
109
switch ( cmd ) {
114
110
case 'rm' : case 'clear' : case 'clean' :
@@ -120,7 +116,7 @@ class Cache extends BaseCommand {
120
116
case 'ls' :
121
117
return await this . ls ( args )
122
118
default :
123
- throw Object . assign ( new Error ( this . usage ) , { code : 'EUSAGE' } )
119
+ throw this . usageError ( )
124
120
}
125
121
}
126
122
@@ -165,14 +161,9 @@ class Cache extends BaseCommand {
165
161
// npm cache add <tarball>...
166
162
// npm cache add <folder>...
167
163
async add ( args ) {
168
- const usage = 'Usage:\n' +
169
- ' npm cache add <tarball-url>...\n' +
170
- ' npm cache add <pkg>@<ver>...\n' +
171
- ' npm cache add <tarball>...\n' +
172
- ' npm cache add <folder>...\n'
173
164
log . silly ( 'cache add' , 'args' , args )
174
165
if ( args . length === 0 )
175
- throw Object . assign ( new Error ( usage ) , { code : 'EUSAGE' } )
166
+ throw this . usageError ( 'First argument to `add` is required' )
176
167
177
168
return Promise . all ( args . map ( spec => {
178
169
log . silly ( 'cache add' , 'spec' , spec )
0 commit comments