diff options
author | isaacs <i@izs.me> | 2010-08-09 20:45:32 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2010-08-09 21:10:25 +0400 |
commit | 1a716a31ca4f6053a8a99a5068580d442ce7e990 (patch) | |
tree | 26be52fa9705cda258437b8bef077b4903d581ac /cli.js | |
parent | 24663af147912749219ad24c1c25e4c956f091c9 (diff) |
Always show help if the args contain --help or -h or -?
Diffstat (limited to 'cli.js')
-rwxr-xr-x | cli.js | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -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) }) |