diff options
author | Gar <gar+gh@danger.computer> | 2021-03-04 07:26:33 +0300 |
---|---|---|
committer | Gar <gar+gh@danger.computer> | 2021-03-09 22:10:06 +0300 |
commit | 9fe0df5b5d7606e5841288d9931be6c04767c9ca (patch) | |
tree | 50b916523fe4a5ebab6010b137cc931cc2a9ce70 /lib/cache.js | |
parent | 85a8694dd9b4a924a474ba75261914511a216868 (diff) |
fix(usage): clean up usage declarations
Small refactor of commands to allow usage to be more programmatically
generated, leading us in the direction of more tighly coupling each
command to the params it accepts.
PR-URL: https://github.com/npm/cli/pull/2821
Credit: @wraithgar
Close: #2821
Reviewed-by: @isaacs
Diffstat (limited to 'lib/cache.js')
-rw-r--r-- | lib/cache.js | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/lib/cache.js b/lib/cache.js index 3ca99fd25..80a5c68eb 100644 --- a/lib/cache.js +++ b/lib/cache.js @@ -4,23 +4,25 @@ const log = require('npmlog') const pacote = require('pacote') const path = require('path') const rimraf = promisify(require('rimraf')) +const BaseCommand = require('./base-command.js') -const usageUtil = require('./utils/usage.js') -class Cache { - constructor (npm) { - this.npm = npm +class Cache extends BaseCommand { + /* istanbul ignore next - see test/lib/load-all-commands.js */ + static get name () { + return 'cache' } - get usage () { - return usageUtil('cache', - 'npm cache add <tarball file>' + - '\nnpm cache add <folder>' + - '\nnpm cache add <tarball url>' + - '\nnpm cache add <git url>' + - '\nnpm cache add <name>@<version>' + - '\nnpm cache clean' + - '\nnpm cache verify' - ) + /* istanbul ignore next - see test/lib/load-all-commands.js */ + static get usage () { + return [ + 'add <tarball file>', + 'add <folder>', + 'add <tarball url>', + 'add <git url>', + 'add <name>@<version>', + 'clean', + 'verify', + ] } async completion (opts) { |