Created
September 29, 2010 12:35
-
-
Save teemow/602676 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/bundle.js b/lib/bundle.js | |
index 4053e60..1653d46 100644 | |
--- a/lib/bundle.js | |
+++ b/lib/bundle.js | |
@@ -5,7 +5,7 @@ var npm = require("../npm") | |
, fs = require("fs") | |
, path = require("path") | |
, log = require("./utils/log") | |
- , cache = require("./cache") | |
+ , readJson = require("./utils/read-json") | |
, mkdir = require("./utils/mkdir-p") | |
, fs = require("./utils/graceful-fs") | |
@@ -27,7 +27,7 @@ function bundle (args, cb) { | |
// AND for my NEXT trick... | |
// add the pkg to the cache, so that we get its data whether it's | |
// a folder or name or whatever, and then delete the cache after. | |
- cache.add(pkg, function (er, data) { | |
+ readJson(path.join(pkg, "package.json"), function (er, data) { | |
if (er) return log.er(cb, "Error adding "+pkg+" to bundle cache")(er) | |
var depNames = Object.keys(data.dependencies) | |
, deps = depNames.map(function (d) { | |
@@ -39,20 +39,13 @@ function bundle (args, cb) { | |
npm.commands.install(deps, function (er) { | |
if (er) return cleanup(er, cb) | |
writeBundleShim(location, depNames, function (er) { | |
- cleanup(er, cb) | |
+ return cb(er) | |
}) | |
}) | |
}) | |
}) | |
} | |
-function cleanup (er_, cb) { | |
- cache.clean(function (er) { | |
- if (er) log.error(er, "Error cleaning bundle cache") | |
- return cb(er_) | |
- }) | |
-} | |
- | |
function writeBundleShim (location, depNames, cb) { | |
var data = "// generated by npm, please don't touch!\n" | |
+ "var i = require.paths.indexOf(__dirname)\n" | |
@@ -63,3 +56,4 @@ function writeBundleShim (location, depNames, cb) { | |
}).join("\n") | |
fs.writeFile(path.join(location, "index.js"), data, cb) | |
} | |
+ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment