diff options
author | isaacs <i@izs.me> | 2010-03-07 23:45:40 +0300 |
---|---|---|
committer | isaacs <i@izs.me> | 2010-03-07 23:45:40 +0300 |
commit | a196844bda3e4fec8b5bb84f5ba7b04bb45b232a (patch) | |
tree | ff60b52c582dd8a36e8b1032740a33dbff9ccadb /cli.js | |
parent | f251b442e5c5eb72f3d9719d3692cae549a4f9f8 (diff) |
Update the bin handling so that it creates a shim for any bin files ending in .js or .node, or shebanged to node or env node. closes #2
Diffstat (limited to 'cli.js')
-rwxr-xr-x | cli.js | 22 |
1 files changed, 5 insertions, 17 deletions
@@ -3,9 +3,6 @@ // usage: // npm [global options] command [command args] -// only run as main module. -if (module.id !== ".") return; - // figure out where we're at. // don't assume that npm is installed in any particular spot, since this // might conceivably be a bootstrap attempt. @@ -13,16 +10,7 @@ var fs = require("fs"), path = require("path"), sys = require("sys"), path = require("path"), - npm; -if (fs.lstatSync(__filename).isSymbolicLink()) { - do { - __filename = fs.readlinkSync(__filename); - npm = path.join(path.dirname(__filename), "npm"); - } while (fs.lstatSync(__filename).isSymbolicLink()); -} else { - npm = path.join(__dirname, "npm"); -} -npm = require(npm); + npm = require("./npm"); // supported commands. var commands = @@ -36,12 +24,12 @@ var commands = , "rm" , "link" ], - log = require(npm.moduleName+"/../lib/utils/log"); + log = require("./lib/utils/log"); -var argv = process.argv, arg = ""; -while (argv.shift() !== module.filename); +// slice off the "node cli.js" or "node /usr/local/bin/npm" from the argv +var argv = process.argv.slice(2), arg = ""; -log(sys.inspect(process.argv), "cli"); +log(sys.inspect(argv), "cli"); // add usage onto any existing help documentation. npm.help = (function (h) { return function () { |