Skip to content

Commit

Permalink
prevent stdout output when -o is used (closes #27)
Browse files Browse the repository at this point in the history
  • Loading branch information
smhg committed Jul 30, 2014
1 parent e87e74b commit 5428cce
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bin/handlebars-xgettext
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ input = argv._;
delete argv._;

parse(input, argv, function (po) {
if (po) {
if (!argv.output && po) {
process.stdout.write(po);
}
});
32 changes: 32 additions & 0 deletions test/cli_test.js
Original file line number Diff line number Diff line change
@@ -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);
Expand Down Expand Up @@ -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();
});
Expand Down

0 comments on commit 5428cce

Please sign in to comment.