From 11d2d35e2c5f946932f4936e5f6c2a3f7ee51bf1 Mon Sep 17 00:00:00 2001 From: isaacs Date: Wed, 25 Aug 2010 17:45:48 -0700 Subject: Don't put the bundle path in require.paths over and over again. --- lib/bundle.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/bundle.js b/lib/bundle.js index 2d8511883..2fb0b3022 100644 --- a/lib/bundle.js +++ b/lib/bundle.js @@ -55,7 +55,9 @@ function cleanup (er_, cb) { function writeBundleShim (location, depNames, cb) { var data = "// generated by npm, please don't touch!\n" - + "require.paths.unshift(__dirname)\n" + + "var i = require.paths.indexOf(__dirname)\n" + + "if (i && i + 1) require.paths.splice(i, 1)\n" + + "if (i) require.paths.shift(__dirname)\n" + depNames.map(JSON.stringify).map(function (d) { return "exports["+d+"] = require("+d+")\n" }) -- cgit v1.2.3