diff options
author | isaacs <i@foohack.com> | 2009-10-05 03:05:26 +0400 |
---|---|---|
committer | isaacs <i@foohack.com> | 2009-10-05 03:05:26 +0400 |
commit | 0101d6bc88d31f4a47007d52caa521f2cff37f1b (patch) | |
tree | c49e6a2f3a29abec42ba292e6fcddb8a2b809c92 /npm.js | |
parent | 0cc345812a85f9e62ef139f6eea06ebd19405849 (diff) |
Add some robustness in the package file lib linking.
Diffstat (limited to 'npm.js')
-rwxr-xr-x | npm.js | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -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; }; |