mirror of
https://github.com/shelljs/shelljs.git
synced 2026-01-25 16:07:37 +00:00
Add newline to output of echo (#557)
* Add newline to output of echo * Add test
This commit is contained in:
parent
0ad6252f2e
commit
5acb353bc5
@ -29,6 +29,6 @@ function _echo(opts, messages) {
|
||||
}
|
||||
|
||||
console.log.apply(console, messages);
|
||||
return messages.join(' ');
|
||||
return messages.join(' ') + '\n';
|
||||
}
|
||||
module.exports = _echo;
|
||||
|
||||
22
test/echo.js
22
test/echo.js
@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user