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-02-22 11:51:38 +0300
committerisaacs <i@izs.me>2010-02-22 11:56:05 +0300
commit3629895cccde19b65daff61312f308a06c5db549 (patch)
tree24b4705cd9b35c0d334a50d764123a9721f40dcf /cli.js
parentc8ef849f24f5e6933bfc3b790cad220e7579eb38 (diff)
Presume that npm is installed when this script is being used.
Use callbacks instead of promises.
Diffstat (limited to 'cli.js')
-rwxr-xr-xcli.js22
1 files changed, 10 insertions, 12 deletions
diff --git a/cli.js b/cli.js
index 694f9c84b..5283969f4 100755
--- a/cli.js
+++ b/cli.js
@@ -1,7 +1,7 @@
#!/usr/bin/env node
// usage:
-// node cli.js [global options] command [command args]
+// npm [global options] command [command args]
// only run as main module.
if (module.id !== ".") return;
@@ -9,22 +9,20 @@ if (module.id !== ".") return;
// supported commands.
var commands = ["help", "install"];
-var npm = require("./npm"),
+var npm = require("npm"),
sys = require("sys"),
path = require("path"),
- log = require("./lib/utils").log,
- Promise = require("events").Promise;
+ log = require("npm/lib/utils").log;
var argv = process.argv, arg = "";
while (argv.shift() !== module.filename);
-function p (m) { sys.error("NPM: "+m); return p };
-
log("cli: "+sys.inspect(process.argv));
+// add usage onto any existing help documentation.
npm.help = (function (h) { return function () {
- h && h.apply(npm, arguments);
usage();
+ h && h.apply(npm, arguments);
}})(npm.help);
var globalOption = (function () {
@@ -57,8 +55,8 @@ function usage () {
("[command options] The arguments to pass to the function.");
}
-var result = npm[command].apply(npm, argv);
-if (result instanceof Promise) result
- .addCallback(function () { log("ok") })
- .addErrback(function () { log("failed") });
-else log("ok");
+var result = npm[command].apply(npm, argv.concat(function (ok, er) {
+ if (er) {
+ log("failed " + er.message);
+ } else log("ok");
+});