Skip to content

Commit 07e2762

Browse files
authoredApr 21, 2020
Prevent extraneous newline from --stdin --fix (#460)
1 parent a592d3d commit 07e2762

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed
 

Diff for: ‎cli-main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ if (options.nodeVersion) {
157157
if (options.fix) {
158158
const result = xo.lintText(stdin, options).results[0];
159159
// If there is no output, pass the stdin back out
160-
console.log(result.output || stdin);
160+
process.stdout.write(result.output || stdin);
161161
return;
162162
}
163163

Diff for: ‎test/cli-main.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ test('fix option', async t => {
1717

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

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

0 commit comments

Comments
 (0)
Please sign in to comment.