From 2dbaf0d208b9d23ca3e49848c0fd98b2c253de68 Mon Sep 17 00:00:00 2001 From: isaacs Date: Tue, 27 Jul 2010 09:53:30 -0700 Subject: First crack at something resembling a fix for #74 --- lib/bundle.js | 22 ++++++++++++++++++++++ npm.js | 1 + 2 files changed, 23 insertions(+) create mode 100644 lib/bundle.js diff --git a/lib/bundle.js b/lib/bundle.js new file mode 100644 index 000000000..5dd6d0b59 --- /dev/null +++ b/lib/bundle.js @@ -0,0 +1,22 @@ + +module.exports = bundle + +var npm = require("../npm") + , fs = require("fs") + , path = require("path") + , log = require("./utils/log") +function bundle (args, cb) { + log(args, "bundle") + var location = args.pop() + , usage = "Usage: npm bundle [ [ ...]] " + if (!location) return cb(new Error(usage)) + if (location.charAt(0) !== "/") { + location = path.join(process.cwd(), location) + } + fs.stat(location, function (er, s) { + if (er || !s.isDirectory()) return cb(new Error(usage)) + npm.config.set("root", location) + npm.config.set("binroot", null) + npm.commands.install(args, cb) + }) +} diff --git a/npm.js b/npm.js index 0b11487de..dc52eae5a 100755 --- a/npm.js +++ b/npm.js @@ -46,6 +46,7 @@ var commandCache = {} , "view" , "repl" , "rebuild" + , "bundle" ].forEach(function (c) { Object.defineProperty(npm.commands, c, { get : function () { c = c === "list" ? "ls" -- cgit v1.2.3