Skip to content
This repository has been archived by the owner on Apr 11, 2018. It is now read-only.

Commit

Permalink
Merge pull request #419 from gustavohenke/patch-1
Browse files Browse the repository at this point in the history
Fixed fs loader to default to cwd if no basepath or relative
  • Loading branch information
paularmstrong committed Feb 11, 2014
2 parents a2100ac + 80343e4 commit 6cff764
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/loaders/filesystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = function (basepath, encoding) {
if (basepath) {
from = basepath;
} else {
from = (from) ? path.dirname(from) : '/';
from = (from) ? path.dirname(from) : process.cwd();
}
return path.resolve(from, to);
};
Expand Down
7 changes: 7 additions & 0 deletions tests/loaders.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ describe('swig.loaders', function () {
done();
});
});

it('takes cwd as default base path', function () {
var filepath = path.relative(process.cwd(), __dirname + '/cases/macros.html'),
s = new swig.Swig();

expect(s.renderFile(filepath)).to.equal(macroExpectation);
});
});

});
Expand Down

0 comments on commit 6cff764

Please sign in to comment.