diff --git a/lib/commands/cache.js b/lib/commands/cache.js index 43f52e4e95e68..587bcbe84ff5d 100644 --- a/lib/commands/cache.js +++ b/lib/commands/cache.js @@ -116,7 +116,7 @@ class Cache extends BaseCommand { case 'ls': return await this.ls(args) default: - throw Object.assign(new Error(this.usage), { code: 'EUSAGE' }) + throw this.usageError(this.usage) } } @@ -168,7 +168,7 @@ class Cache extends BaseCommand { ' npm cache add ...\n' log.silly('cache add', 'args', args) if (args.length === 0) - throw Object.assign(new Error(usage), { code: 'EUSAGE' }) + throw this.usageError(usage) return Promise.all(args.map(spec => { log.silly('cache add', 'spec', spec)