| @@ -2,20 +2,19 @@ require('./helper'); | |||||
| var fs = require('fs'); | var fs = require('fs'); | ||||
| var path = require('path'); | var path = require('path'); | ||||
| var child_process = require('child_process'); | |||||
| var _files = path.join(__dirname, '_files'); | var _files = path.join(__dirname, '_files'); | ||||
| var cliTxt = path.resolve(_files, 'cli.txt'); | var cliTxt = path.resolve(_files, 'cli.txt'); | ||||
| var cliPartialsTxt = path.resolve(_files, 'cli_with_partials.txt'); | var cliPartialsTxt = path.resolve(_files, 'cli_with_partials.txt'); | ||||
| var moduleVersion = require('../package').version; | var moduleVersion = require('../package').version; | ||||
| var child_process = require('child_process'); | |||||
| function changeForOS(command) { | function changeForOS(command) { | ||||
| if(process.platform === 'win32') { | if(process.platform === 'win32') { | ||||
| return command. | |||||
| replace(/bin\/mustache/g, 'node bin\\mustache'). | |||||
| replace(/\bcat\b/g, 'type'). | |||||
| replace(/\//g, '\\'); | |||||
| return command | |||||
| .replace(/bin\/mustache/g, 'node bin\\mustache') | |||||
| .replace(/\bcat\b/g, 'type') | |||||
| .replace(/\//g, '\\'); | |||||
| } | } | ||||
| return command; | return command; | ||||
| @@ -31,7 +30,6 @@ describe('Mustache CLI', function () { | |||||
| var expectedOutput; | var expectedOutput; | ||||
| it('writes syntax hints into stderr when runned with wrong number of arguments', function(done) { | it('writes syntax hints into stderr when runned with wrong number of arguments', function(done) { | ||||
| exec('bin/mustache', function(err, stdout, stderr) { | exec('bin/mustache', function(err, stdout, stderr) { | ||||
| assert.notEqual(stderr.indexOf('Syntax'), -1); | assert.notEqual(stderr.indexOf('Syntax'), -1); | ||||
| done(); | done(); | ||||
| @@ -101,17 +99,14 @@ describe('Mustache CLI', function () { | |||||
| it('writes it couldnt find template into stderr when second argument doesnt resolve to a file', function(done) { | it('writes it couldnt find template into stderr when second argument doesnt resolve to a file', function(done) { | ||||
| exec('bin/mustache test/_files/cli.json test/_files/non-existing-template.mustache', function(err, stdout, stderr) { | exec('bin/mustache test/_files/cli.json test/_files/non-existing-template.mustache', function(err, stdout, stderr) { | ||||
| console.log(stderr); | |||||
| assert.notEqual(stderr.indexOf('Could not find file:'), -1); | |||||
| assert.notEqual(stderr.indexOf(changeForOS('test/_files/non-existing-template.mustache')), -1); | |||||
| assert.isOk(/Could not find file: .+non-existing-template\.mustache/.test(stderr)); | |||||
| done(); | done(); | ||||
| }); | }); | ||||
| }); | }); | ||||
| it('writes it couldnt find view into stderr when first argument doesnt resolve to a file', function(done) { | it('writes it couldnt find view into stderr when first argument doesnt resolve to a file', function(done) { | ||||
| exec('bin/mustache test/_files/non-existing-view.json test/_files/cli.mustache', function(err, stdout, stderr) { | exec('bin/mustache test/_files/non-existing-view.json test/_files/cli.mustache', function(err, stdout, stderr) { | ||||
| assert.notEqual(stderr.indexOf('Could not find file:'), -1); | |||||
| assert.notEqual(stderr.indexOf(changeForOS('test/_files/non-existing-view.json')), -1); | |||||
| assert.isOk(/Could not find file: .+non-existing-view\.json/.test(stderr)); | |||||
| done(); | done(); | ||||
| }); | }); | ||||
| }); | }); | ||||