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
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2010-03-21 22:16:07 +0300
committerisaacs <i@izs.me>2010-03-21 22:16:07 +0300
commit4d05b0461351c041801aecb01444b69916421d83 (patch)
treea48bd285d9b37366a3bc32ba234633cdf43bede8
parent921cb0200185687d491627b6cd8a88bf89614317 (diff)
Updated to work with node 0.1.33 with the various net2 changes.
-rw-r--r--install-npm.js4
-rw-r--r--lib/ls.js1
-rw-r--r--lib/utils/exec.js22
-rwxr-xr-xnpm.js20
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!");
});
})
diff --git a/lib/ls.js b/lib/ls.js
index 3c38fe32c..c3a20ce13 100644
--- a/lib/ls.js
+++ b/lib/ls.js
@@ -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);
+ });
}
diff --git a/npm.js b/npm.js
index f9505d32e..96f96a73a 100755
--- a/npm.js
+++ b/npm.js
@@ -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
+ });