Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent extraneous newline from --stdin --fix #460

Merged
merged 1 commit into from Apr 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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