diff options
author | isaacs <i@izs.me> | 2010-04-27 03:43:17 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2010-04-27 03:43:17 +0400 |
commit | de6c168f0e9ce0d8e734446d9fd1ade61575854c (patch) | |
tree | 71987576732344ff1b10db3eb2bff09f028853a5 /cli.js | |
parent | f2ef34d846d15717d22f98434d1932a3d60fdaf5 (diff) |
support overriding config options just for one command on the command line using --options
Diffstat (limited to 'cli.js')
-rwxr-xr-x | cli.js | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -21,16 +21,25 @@ var fs = require("fs") log(sys.inspect(argv), "cli") while (arg = argv.shift()) { - if (!command && (arg in npm.commands)) command = arg - else if (!key && arg.charAt(0) === "-") key = arg.replace(/^-+/, '') - else if (key) { + if (!command && (arg in npm.commands)) { + if (key) { + conf[key] = true + key = null + } + command = arg + } else if (arg.substr(0, 2) === "--") { + if (key) conf[key] = true + key = arg.substr(2) + } else if (key) { conf[key] = arg key = null } else arglist.push(arg) } if (key) conf[key] = true -if (!command) npm.commands.help([]) +for (var k in conf) npm.config.set(k, conf[k]) + +if (!command) npm.commands.help([arglist.join(" ")]) else npm.commands[command](arglist, conf, function (er, ok) { if (er) { npm.commands.help([command], conf, function () { |