diff options
author | isaacs <i@izs.me> | 2010-02-18 04:09:41 +0300 |
---|---|---|
committer | isaacs <i@izs.me> | 2010-02-18 04:09:41 +0300 |
commit | 8ec8959f67eef723a50ff0c21360bc454defd244 (patch) | |
tree | a688eeae85b25ed8d7b4f9737a666443db7bd85e /cli.js | |
parent | a5ef5db11e1845580c443134c3c76eb16022f972 (diff) |
Slight CLI tweaks.
Diffstat (limited to 'cli.js')
-rwxr-xr-x | cli.js | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -12,7 +12,8 @@ var commands = ["help", "install"]; var npm = require("./npm"), sys = require("sys"), path = require("path"), - log = require("./lib/utils").log; + log = require("./lib/utils").log, + Promise = require("events").Promise; var argv = process.argv, arg = ""; while (argv.shift() !== module.filename); @@ -42,8 +43,6 @@ while (arg = argv.shift()) { } else globalOption(arg); } -return npm[command].apply(npm, argv); - function usage () { var out = (arg === "help" ? "puts" : "error"); function p (m) { sys[out](m); return p }; @@ -57,3 +56,9 @@ function usage () { (" Supported: "+commands) ("[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"); |