From 07e2762b48d1d641406274ba2cd362d214468b59 Mon Sep 17 00:00:00 2001 From: Charlie Johnson Date: Tue, 21 Apr 2020 03:55:27 -0500 Subject: [PATCH] Prevent extraneous newline from `--stdin --fix` (#460) --- cli-main.js | 2 +- test/cli-main.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cli-main.js b/cli-main.js index 04467880..39951c6d 100755 --- a/cli-main.js +++ b/cli-main.js @@ -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; } diff --git a/test/cli-main.js b/test/cli-main.js index 2bb9e303..73079175 100644 --- a/test/cli-main.js +++ b/test/cli-main.js @@ -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 => {