Fix typos in bundler that prevented normal bundling

This commit is contained in:
Geoff Schmidt
2013-04-16 19:49:09 -07:00
committed by David Glasser
parent 2c1b297dc1
commit 54ca2a4463
2 changed files with 22 additions and 9 deletions

View File

@@ -340,15 +340,15 @@ _.extend(Builder.prototype, {
// Returns a new Builder-compatible object that works just like a
// Builder, but interprets all paths relative to 'relPath', a path
// relative to the bundle root.
// relative to the bundle root which should not start with a '/'.
//
// The sub-builder returned does not have all Builder methods (for
// example, complete() wouldn't make sense) and you should not rely
// on it beig instanceof Builder.
// on it being instanceof Builder.
enter: function (relPath) {
var self = this;
var methods = ["write", "writeJson", "reserve", "copyDirectory",
"enter"];
var methods = ["write", "writeJson", "reserve", "generateFilename",
"copyDirectory", "enter"];
var ret = {};
_.each(methods, function (method) {
@@ -366,7 +366,20 @@ _.extend(Builder.prototype, {
args[0].to = path.join(relPath, args[0].to);
}
return self[method].apply(self, args);
var ret = self[method].apply(self, args);
if (method === "generateFilename") {
// fix up the returned path to be relative to the
// sub-bundle, not the parent bundle
if (ret.substr(0, 1) === '/')
ret = ret.substr(1);
if (ret.substr(0, relPath.length) !== relPath)
throw new Error("generateFilename returned path outside of " +
"sub-bundle?");
ret = ret.substr(relPath.length);
}
return ret;
};
});

View File

@@ -167,7 +167,7 @@ var NodeModulesDirectory = function (options) {
// The path (relative to the bundle root) where we would preferably
// like the node_modules to be output (essentially cosmetic.)
self.preferredBundlePath = options.bundlePath;
self.preferredBundlePath = options.preferredBundlePath;
};
///////////////////////////////////////////////////////////////////////////////
@@ -349,11 +349,11 @@ _.extend(Target.prototype, {
if (typeof p === "string")
return library.getSlices(p, self.arch);
else
return pkg.getDefaultSlices(self.arch);
return p.getDefaultSlices(self.arch);
}),
_.map(options.test || [], function (p) {
var pkg = (p === "string" ? library.get(p) : p);
return p.getTestSlices(self.arch);
var pkg = (typeof p === "string" ? library.get(p) : p);
return pkg.getTestSlices(self.arch);
})
]);
_.each(rootSlices, function (slice) {