Skip to content

Commit

Permalink
Force unix style path separators in precompile (#761)
Browse files Browse the repository at this point in the history
* Force unix style path seperators in precompile

* Switched path sep replace, to use Regex

* Added test to confirm that path seperators are always *NIX, irrespective of precompiling platform
  • Loading branch information
kim3er authored and carljm committed May 27, 2016
1 parent a607755 commit 85adf4c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/precompile.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ function precompile(input, opts) {
for(var i=0; i<templates.length; i++) {
var name = templates[i].replace(path.join(input, '/'), '');

name = name.replace(/\\/g, '/');

try {
precompiled.push( _precompile(
fs.readFileSync(templates[i], 'utf-8'),
Expand Down
14 changes: 14 additions & 0 deletions tests/precompile.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,19 @@
it('should return a string', function() {
expect(precompileString('{{ test }}', { name: 'test.j2' })).to.be.an('string');
});

describe('templates', function() {
it('should return *NIX path seperators', function() {
var fileName;

precompile('./tests/templates/item.j2', {
wrapper: function(templates) {
fileName = templates[0].name;
}
});

expect(fileName).to.not.contain('\\');
});
});
});
})();

0 comments on commit 85adf4c

Please sign in to comment.