Permalink
Browse files

CWD solution for local paths

  • Loading branch information...
robashton committed Mar 26, 2012
1 parent b97a2b1 commit 1a86a2ed2ac732574adfab7801a64a5370eabb31
View
@@ -18,15 +18,20 @@ module.exports = (function(require) {
Builder.prototype = {
run: function() {
+ var oldWd = process.cwd();
+ process.chdir(this.cfg.root || oldWd);
+
var root = new DirectoryWalker(this.cfg.in);
var self = this;
root.on('error', function(err) {
self.emit('error', err);
+ process.chdir(oldWd);
});
root.on('completed', function() {
self.completed = true;
+ process.chdir(oldWd);
});
root.on('file', function(path) {
@@ -62,9 +67,6 @@ module.exports = (function(require) {
}
handler.handle(path, function(err, data) {
if(err) { self.emit('error', err); return; }
- if(self.cfg.root) {
- path = path.replace(self.cfg.root, '');
- }
self.data[path] = data;
self.notifyPendingDecrease();
});

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -91,9 +91,9 @@ describe("Packaging a directory with a root specified", function() {
before(function(done) {
swallowTests.packageDirectoryAndLoadPackage({
- in: './in/assets',
+ in: './assets',
out: './out/packaging_directory_with_root_specified.json',
- root: 'in/assets'
+ root: 'in'
},
function(err, pkg) {
if(err) throw err;
@@ -103,8 +103,8 @@ describe("Packaging a directory with a root specified", function() {
});
it("Should remove the root from the path", function() {
- var packageJson = builtPackage.getRaw('/models/hovercraft.json');
- assert(packageJson)
+ var packageJson = builtPackage.getRaw('assets/models/hovercraft.json');
+ assert(packageJson);
});
});

0 comments on commit 1a86a2e

Please sign in to comment.