set.js 632 B

123456789101112131415161718192021222324
  1. const Npm = require('../npm.js')
  2. const BaseCommand = require('../base-cmd.js')
  3. class Set extends BaseCommand {
  4. static description = 'Set a value in the npm configuration'
  5. static name = 'set'
  6. static usage = ['<key>=<value> [<key>=<value> ...] (See `npm config`)']
  7. static params = ['global', 'location']
  8. static ignoreImplicitWorkspace = false
  9. static async completion (opts) {
  10. const Config = Npm.cmd('config')
  11. return Config.completion(opts)
  12. }
  13. async exec (args) {
  14. if (!args.length) {
  15. throw this.usageError()
  16. }
  17. return this.npm.exec('config', ['set'].concat(args))
  18. }
  19. }
  20. module.exports = Set