Skip to content

Commit

Permalink
Prevent extraneous newline from --stdin --fix (#460)
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesbjohnson committed Apr 21, 2020
1 parent a592d3d commit 07e2762
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cli-main.js
Expand Up @@ -157,7 +157,7 @@ if (options.nodeVersion) {
if (options.fix) {
const result = xo.lintText(stdin, options).results[0];
// If there is no output, pass the stdin back out
console.log(result.output || stdin);
process.stdout.write(result.output || stdin);
return;
}

Expand Down
4 changes: 2 additions & 2 deletions test/cli-main.js
Expand Up @@ -17,9 +17,9 @@ test('fix option', async t => {

test('fix option with stdin', async t => {
const {stdout} = await main(['--fix', '--stdin'], {
input: 'console.log()\n'
input: 'console.log()'
});
t.is(stdout.trim(), 'console.log();');
t.is(stdout, 'console.log();');
});

test('stdin-filename option with stdin', async t => {
Expand Down

0 comments on commit 07e2762

Please sign in to comment.