Skip to content

Commit f8397ba

Browse files
committed
Rename stripEof option to stripFinalNewline
See sindresorhus/strip-final-newline#1
1 parent 0e780f8 commit f8397ba

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

index.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
const path = require('path');
33
const childProcess = require('child_process');
44
const crossSpawn = require('cross-spawn');
5-
const stripEof = require('strip-eof');
5+
const stripFinalNewline = require('strip-final-newline');
66
const npmRunPath = require('npm-run-path');
77
const isStream = require('is-stream');
88
const _getStream = require('get-stream');
@@ -44,14 +44,19 @@ function handleArgs(cmd, args, opts) {
4444
opts = Object.assign({
4545
maxBuffer: TEN_MEGABYTES,
4646
buffer: true,
47-
stripEof: true,
47+
stripFinalNewline: true,
4848
preferLocal: true,
4949
localDir: parsed.options.cwd || process.cwd(),
5050
encoding: 'utf8',
5151
reject: true,
5252
cleanup: true
5353
}, parsed.options);
5454

55+
// TODO: Remove in the next major release
56+
if (opts.stripEof === false) {
57+
opts.stripFinalNewline = false;
58+
}
59+
5560
opts.stdio = stdio(opts);
5661

5762
if (opts.preferLocal) {
@@ -89,8 +94,8 @@ function handleInput(spawned, input) {
8994
}
9095

9196
function handleOutput(opts, val) {
92-
if (val && opts.stripEof) {
93-
val = stripEof(val);
97+
if (val && opts.stripFinalNewline) {
98+
val = stripFinalNewline(val);
9499
}
95100

96101
return val;

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"npm-run-path": "^2.0.0",
4444
"p-finally": "^1.0.0",
4545
"signal-exit": "^3.0.0",
46-
"strip-eof": "^1.0.0"
46+
"strip-final-newline": "^2.0.0"
4747
},
4848
"devDependencies": {
4949
"ava": "*",

readme.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,12 @@ Default: `false`
195195

196196
If `true`, runs `command` inside of a shell. Uses `/bin/sh` on UNIX and `cmd.exe` on Windows. A different shell can be specified as a string. The shell should understand the `-c` switch on UNIX or `/d /s /c` on Windows.
197197

198-
#### stripEof
198+
#### stripFinalNewline
199199

200200
Type: `boolean`<br>
201201
Default: `true`
202202

203-
[Strip EOF](https://github.com/sindresorhus/strip-eof) (last newline) from the output.
203+
Strip the final [newline character](https://en.wikipedia.org/wiki/Newline) from the output.
204204

205205
#### preferLocal
206206

test.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,16 @@ test('skip throwing when using reject option in execa.shellSync()', t => {
138138
t.is(typeof err.stderr, 'string');
139139
});
140140

141-
test('stripEof option', async t => {
141+
test('stripEof option (legacy)', async t => {
142142
const {stdout} = await m('noop', ['foo'], {stripEof: false});
143143
t.is(stdout, 'foo\n');
144144
});
145145

146+
test('stripFinalNewline option', async t => {
147+
const {stdout} = await m('noop', ['foo'], {stripFinalNewline: false});
148+
t.is(stdout, 'foo\n');
149+
});
150+
146151
test.serial('preferLocal option', async t => {
147152
t.true((await m('cat-names')).stdout.length > 2);
148153

0 commit comments

Comments
 (0)