diff --git a/jakefile.js b/jakefile.js index 3953160a..7f601051 100644 --- a/jakefile.js +++ b/jakefile.js @@ -1,4 +1,5 @@ var fs = require('fs'); +var path = require('path'); var execSync = require('child_process').execSync; var exec = function (cmd) { execSync(cmd, {stdio: 'inherit'}); @@ -19,31 +20,36 @@ task('clean', ['clobber'], function () { desc('Lints the source code'); task('lint', ['clean'], function () { - exec('./node_modules/.bin/eslint "**/*.js"'); + var epath = path.join('./node_modules/.bin/eslint'); + exec(epath+' "**/*.js"'); console.log('Linting completed.'); }); task('browserify', function () { - exec('./node_modules/browserify/bin/cmd.js --standalone ejs lib/ejs.js > ejs.js'); + var epath = path.join('./node_modules/browserify/bin/cmd.js'); + exec(epath+' --standalone ejs lib/ejs.js > ejs.js'); console.log('Browserification completed.'); }); task('minify', function () { - exec('./node_modules/uglify-js/bin/uglifyjs ejs.js > ejs.min.js'); + var epath = path.join('./node_modules/uglify-js/bin/uglifyjs'); + exec(epath+' ejs.js > ejs.min.js'); console.log('Minification completed.'); }); desc('Generates the EJS API docs for the public API'); task('doc', function () { jake.rmRf('out'); - exec('./node_modules/.bin/jsdoc --verbose -c jsdoc.json lib/* docs/jsdoc/*'); + var epath = path.join('./node_modules/.bin/jsdoc'); + exec(epath+' --verbose -c jsdoc.json lib/* docs/jsdoc/*'); console.log('Documentation generated in ./out.'); }); desc('Generates the EJS API docs for the public and private API'); task('devdoc', function () { jake.rmRf('out'); - exec('./node_modules/.bin/jsdoc --verbose -p -c jsdoc.json lib/* docs/jsdoc/*'); + var epath = path.join('./node_modules/.bin/jsdoc'); + exec(epath+' --verbose -p -c jsdoc.json lib/* docs/jsdoc/*'); console.log('Documentation generated in ./out.'); }); @@ -51,13 +57,14 @@ desc('Publishes the EJS API docs'); task('docPublish', ['doc'], function () { fs.writeFileSync('out/CNAME', 'api.ejs.co'); console.log('Pushing docs to gh-pages...'); - exec('./node_modules/.bin/git-directory-deploy --directory out/'); + var epath = path.join('./node_modules/.bin/git-directory-deploy'); + exec(epath+' --directory out/'); console.log('Docs published to gh-pages.'); }); desc('Runs the EJS test suite'); task('test', ['lint'], function () { - exec('./node_modules/.bin/mocha'); + exec(path.join('./node_modules/.bin/mocha')); }); publishTask('ejs', ['build'], function () { diff --git a/test/cli.js b/test/cli.js index 65c0fafa..81b1d5e9 100644 --- a/test/cli.js +++ b/test/cli.js @@ -1,6 +1,9 @@ let exec = require('child_process').execSync; let fs = require('fs'); +let path = require('path'); let assert = require('assert'); +let os = process.platform !== 'win32' ? '' : 'node '; +let lf = process.platform !== 'win32' ? '\n' : '\r\n'; function run(cmd) { return exec(cmd).toString(); @@ -8,35 +11,47 @@ function run(cmd) { suite('cli', function () { test('rendering, custom delimiter, passed data', function () { - let o = run('./bin/cli.js -m $ ./test/fixtures/user.ejs name=foo'); - assert.equal(o, '
hey
\n'); + assert.equal(html, 'hey
'+lf); done(); }); }); @@ -392,7 +393,7 @@ suite('ejs.renderFile(path, [data], [options], [fn])', function () { var AsyncCtor; var func; function checkResult(html) { - assert.equal(html, 'hey
\n'); + assert.equal(html, 'hey
'+lf); } // Environments without Promise support -- should throw // when no callback provided @@ -440,7 +441,7 @@ suite('ejs.renderFile(path, [data], [options], [fn])', function () { if (err) { return done(err); } - assert.equal(html, 'global test
\nglobal test
'+lf+'custom test
\ncustom test
'+lf+'This is a file with BOM.
\n'); + 'This is a file with BOM.
'+lf); }); test('include ejs with locals', function () { @@ -1003,8 +1010,10 @@ suite('include()', function () { var file = 'test/fixtures/include-root.ejs'; var inc = function (original, prev) { if (original.charAt(0) === '/') { + // original: '/include' (windows) + // prev: 'D:\include.ejs' (windows) return { - filename: path.join(__dirname, 'fixtures', prev) + filename: path.join(__dirname, 'fixtures', original+'.ejs') }; } else { return prev; @@ -1017,9 +1026,11 @@ suite('include()', function () { test('include ejs with includer returning template', function () { var file = 'test/fixtures/include-root.ejs'; var inc = function (original, prev) { - if (prev === '/include.ejs') { + // original: '/include' (windows) + // prev: 'D:\include.ejs' (windows) + if (original === '/include') { return { - template: 'Hello template!
\n' + template: 'Hello template!
'+lf }; } else { return prev; @@ -1073,10 +1084,10 @@ suite('include()', function () { var file = 'test/fixtures/include_cache.ejs'; var options = {filename: file}; var out = ejs.compile(fixture('include_cache.ejs'), options); - assert.equal(out(), 'Old
\n'); + assert.equal(out(), 'Old
'+lf); fs.writeFileSync(__dirname + '/tmp/include.ejs', 'New
'); - assert.equal(out(), 'New
\n'); + assert.equal(out(), 'New
'+lf); }); test('support caching', function () { @@ -1126,7 +1137,7 @@ suite('test fileloader', function () { if (err) { return done(err); } - assert.equal(html, 'myFileLoad:hey
\n'); + assert.equal(html, 'myFileLoad:hey
'+lf); done(); });