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/npm.js
diff options
context:
space:
mode:
authorisaacs <i@foohack.com>2009-10-05 03:05:26 +0400
committerisaacs <i@foohack.com>2009-10-05 03:05:26 +0400
commit0101d6bc88d31f4a47007d52caa521f2cff37f1b (patch)
treec49e6a2f3a29abec42ba292e6fcddb8a2b809c92 /npm.js
parent0cc345812a85f9e62ef139f6eea06ebd19405849 (diff)
Add some robustness in the package file lib linking.
Diffstat (limited to 'npm.js')
-rwxr-xr-xnpm.js15
1 files changed, 12 insertions, 3 deletions
diff --git a/npm.js b/npm.js
index 9f7c14121..6d46b228c 100755
--- a/npm.js
+++ b/npm.js
@@ -87,14 +87,19 @@ function _install (name, data, opt) {
function linkPkgLib (name, data) {
var p = new node.Promise();
- log("linkPkgLib " + data.lib, name);
var targetFile = node.path.join(ENV.HOME, ".node_libraries", name+".js");
+ log("linking /"+name+".js to /"+name+"/" + data.lib, name);
+
+ var relPath = [ENV.HOME, ".node_libraries", name].concat(data.lib.split("/"));
+ relPath = node.path.join.apply(node.path, relPath);
+ relPath = relPath.replace(/"/g, "\\\"");
+
node.fs.open(targetFile,
node.O_CREAT | node.O_TRUNC | node.O_WRONLY,
0755
).addErrback(fail(p, "Couldn't create "+targetFile))
.addCallback(function (fd) {
- node.fs.write(fd, 'setExports(require("./'+name+'/'+data.lib+'"));\n')
+ node.fs.write(fd, 'setExports(require("'+relPath+'"));\n')
.addErrback(fail(p, "Couldn't write code to "+targetFile))
.addCallback(method(p, "emitSuccess"));
});
@@ -102,8 +107,12 @@ function linkPkgLib (name, data) {
return p;
};
function buildPkg (name, data) {
- log("buildPkg " + data.build, name);
+ log(data.build, name);
var p = new node.Promise();
+
+ // exec("cd "+
+ // node.path.join(ENV.HOME, ".node_libraries", name+".js")
+ // )
setTimeout(method(p, "emitSuccess"));
return p;
};