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-08-09 20:45:32 +0400
committerisaacs <i@izs.me>2010-08-09 21:10:25 +0400
commit1a716a31ca4f6053a8a99a5068580d442ce7e990 (patch)
tree26be52fa9705cda258437b8bef077b4903d581ac /cli.js
parent24663af147912749219ad24c1c25e4c956f091c9 (diff)
Always show help if the args contain --help or -h or -?
Diffstat (limited to 'cli.js')
-rwxr-xr-xcli.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/cli.js b/cli.js
index c4fe26fd5..b747375a0 100755
--- a/cli.js
+++ b/cli.js
@@ -26,6 +26,7 @@ var fs = require("fs")
log(argv, "cli")
while (arg = argv.shift()) {
+ if (!key && (arg === "-h" || arg === "-?")) arg = "--help"
if (!command && (npm.commands.hasOwnProperty(arg))) {
if (key) {
conf[key] = true
@@ -35,6 +36,7 @@ while (arg = argv.shift()) {
} else if (!flagsDone && arg.substr(0, 2) === "--") {
if (key) conf[key] = true
key = arg.substr(2)
+ if (key === "help") conf[key] = true, key = null
flagsDone = (key === "")
} else if (key) {
conf[key] = arg
@@ -56,7 +58,7 @@ process.on("exit", function () { if (!itWorked) log("not ok") })
var itWorked = false
-if (!command) {
+if (!command && !conf.help) {
if (!printVersion) {
// npm.commands.help([arglist.join(" ")])
if (arglist.length) log(arglist, "unknown command")
@@ -71,6 +73,10 @@ if (!command) {
} else {
ini.resolveConfigs(conf, function (er) {
if (er) return errorHandler(er)
+ if (npm.config.get("help") && command !== "help") {
+ arglist.unshift(command)
+ command = "help"
+ }
npm.config.set("root", ini.get("root"))
npm.commands[command](arglist, errorHandler)
})