Add newline to output of echo (#557)

* Add newline to output of echo

* Add test
This commit is contained in:
Brandon Freitag 2016-11-27 13:12:26 -08:00 committed by Nate Fischer
parent 0ad6252f2e
commit 5acb353bc5
2 changed files with 23 additions and 1 deletions

View File

@ -29,6 +29,6 @@ function _echo(opts, messages) {
}
console.log.apply(console, messages);
return messages.join(' ');
return messages.join(' ') + '\n';
}
module.exports = _echo;

View File

@ -5,6 +5,14 @@ import utils from './utils/utils';
shell.config.silent = true;
test.beforeEach(t => {
t.context.tmp = utils.getTempDir();
});
test.afterEach.always(t => {
shell.rm('-rf', t.context.tmp);
});
//
// Valids
//
@ -57,3 +65,17 @@ test.cb('-e option', t => {
t.end();
});
});
test.cb('piping to a file', t => {
// see issue #476
shell.mkdir(t.context.tmp);
const tmp = `${t.context.tmp}/echo.txt`;
const script = `require('../global.js'); echo('A').toEnd('${tmp}'); echo('B').toEnd('${tmp}');`;
utils.runScript(script, (err, stdout) => {
const result = shell.cat(tmp);
t.falsy(err);
t.is(stdout, 'A\nB\n');
t.is(result.toString(), 'A\nB\n');
t.end();
});
});