diff options
author | isaacs <i@izs.me> | 2010-03-21 22:16:07 +0300 |
---|---|---|
committer | isaacs <i@izs.me> | 2010-03-21 22:16:07 +0300 |
commit | 4d05b0461351c041801aecb01444b69916421d83 (patch) | |
tree | a48bd285d9b37366a3bc32ba234633cdf43bede8 | |
parent | 921cb0200185687d491627b6cd8a88bf89614317 (diff) |
Updated to work with node 0.1.33 with the various net2 changes.
-rw-r--r-- | install-npm.js | 4 | ||||
-rw-r--r-- | lib/ls.js | 1 | ||||
-rw-r--r-- | lib/utils/exec.js | 22 | ||||
-rwxr-xr-x | npm.js | 20 |
4 files changed, 21 insertions, 26 deletions
diff --git a/install-npm.js b/install-npm.js index f32a336b5..aa4443a51 100644 --- a/install-npm.js +++ b/install-npm.js @@ -1,7 +1,5 @@ var sys = require("sys"); -function print (m, cr) { process.stdio.writeError(m+(cr===false?"":"\n")); return print }; - var npm = require("./npm"), sys = require("sys"); npm.install("http://github.com/isaacs/npm/tarball/master", function (er) { if (er) { @@ -14,6 +12,6 @@ npm.install("http://github.com/isaacs/npm/tarball/master", function (er) { sys.error("\nFailed to activate\n"); throw er; } - print("It worked!"); + sys.puts("It worked!"); }); }) @@ -12,6 +12,7 @@ function ls (pkg, cb) { cb = pkg; pkg = false; } + log("about to readdir: "+npm.dir); fs.readdir(npm.dir, function (er, packages) { if (er) return cb(er); packages = packages.filter(function (dir) { diff --git a/lib/utils/exec.js b/lib/utils/exec.js index 1858823f5..bc0a8aa3b 100644 --- a/lib/utils/exec.js +++ b/lib/utils/exec.js @@ -7,15 +7,15 @@ module.exports = function exec (cmd, args, env, cb) { env = null; } log(cmd+" "+args.map(JSON.stringify).join(" "), "exec"); - process.createChildProcess(cmd, args, env) - .addListener("error", function (chunk) { - if (chunk) process.stdio.writeError(chunk) - }) - .addListener("output", function (chunk) { - if (chunk) process.stdio.write(chunk) - }) - .addListener("exit", function (code) { - if (code) cb(new Error("`"+cmd+"` failed with "+code)); - else cb(null, code); - }); + var cp = require("child_process").spawn(cmd, args, env); + cp.stdout.addListener("data", function (chunk) { + if (chunk) process.stdout.write(chunk) + }); + cp.stderr.addListener("data", function (chunk) { + if (chunk) process.binding('stdio').writeError(chunk); + }); + cp.addListener("exit", function (code) { + if (code) cb(new Error("`"+cmd+"` failed with "+code)); + else cb(null, code); + }); } @@ -1,18 +1,8 @@ -// always return the same npm object. This is important, as -// programs might want to set the paths or other things. -var moduleName = __filename.replace(/\.js$/, ''); -if (module.id !== moduleName) { - module.exports = require(moduleName); - return; -} - var npm = exports, set = require("./lib/utils/set"), get = require("./lib/utils/get"); -npm.moduleName = moduleName; - npm.config = {}; // TODO: read configs from a conf file or cli @@ -48,6 +38,12 @@ npm.get = function (name) { return get(registry, name) }; var path = require("path"); npm.root = path.join(process.env.HOME, ".node_libraries"); -npm.__defineGetter__("dir", function () { return path.join(npm.root, ".npm") }); -npm.__defineGetter__("tmp", function () { return path.join(npm.dir, ".tmp") }); +Object.defineProperty(npm, "dir", + { get: function () { return path.join(npm.root, ".npm") } + , enumerable:true + }); +Object.defineProperty(npm, "tmp", + { get: function () { return path.join(npm.dir, "tmp") } + , enumerable:true + }); |