diff --git a/bin/handlebars-xgettext b/bin/handlebars-xgettext index c79698d..670e647 100755 --- a/bin/handlebars-xgettext +++ b/bin/handlebars-xgettext @@ -50,7 +50,7 @@ input = argv._; delete argv._; parse(input, argv, function (po) { - if (po) { + if (!argv.output && po) { process.stdout.write(po); } }); diff --git a/test/cli_test.js b/test/cli_test.js index ff128a7..6c6c9e0 100644 --- a/test/cli_test.js +++ b/test/cli_test.js @@ -1,8 +1,14 @@ var spawn = require('child_process').spawn, + fs = require('fs'), path = require('path'); var bin = path.resolve(__dirname + '/../bin/handlebars-xgettext'); +var tmpDir = path.resolve(__dirname + '/../tmp'); +if (!fs.existsSync(tmpDir)) { + fs.mkdirSync(tmpDir); +} + exports.cli = { 'no parameters': function (test) { test.expect(1); @@ -69,6 +75,32 @@ exports.cli = { throw err; }); + child.on('exit', function () { + test.done(); + }); + }, + 'output': function (test) { + test.expect(0); + + var child = spawn('node', [ + bin, + '--output=../tmp/cli-output.po', + 'fixtures/template.hbs' + ], { + cwd: __dirname, + stdio: ['ignore', null, null] + }); + + child.stdout.setEncoding('utf8'); + + child.stdout.on('data', function () { + throw 'There should not be any output'; + }); + + child.stderr.on('data', function (err) { + throw err; + }); + child.on('exit', function () { test.done(); });