Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/cli.js
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2010-04-27 03:43:17 +0400
committerisaacs <i@izs.me>2010-04-27 03:43:17 +0400
commitde6c168f0e9ce0d8e734446d9fd1ade61575854c (patch)
tree71987576732344ff1b10db3eb2bff09f028853a5 /cli.js
parentf2ef34d846d15717d22f98434d1932a3d60fdaf5 (diff)
support overriding config options just for one command on the command line using --options
Diffstat (limited to 'cli.js')
-rwxr-xr-xcli.js17
1 files changed, 13 insertions, 4 deletions
diff --git a/cli.js b/cli.js
index e09c569a8..a08f7d8e3 100755
--- a/cli.js
+++ b/cli.js
@@ -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 () {