Rename `stripEof` option to `stripFinalNewline`
Before adoption: this commit came in with the history the project adopted, so no landing records it.
See https://github.com/sindresorhus/strip-final-newline/issues/1
authored by Sindre Sorhus · committed by Sindre Sorhus · parent 0e780f8 · Browse files · 4 files·+18 added−8 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+18 added−8 removed
- other:+18 added−8 removed
Provenance
- Commit
f8397ba- Tree
dd773ea- Author
Sindre Sorhus <sindresorhus@gmail.com>- Committer
Sindre Sorhus <sindresorhus@gmail.com>- Parent
0e780f8
4 files changed+18 added−8 removed
modified:index.js+9 added-4 removed
1 'use strict';2 const path = require('path');3 const childProcess = require('child_process');4 const crossSpawn = require('cross-spawn');5-const stripEof = require('strip-eof');5+const stripFinalNewline = require('strip-final-newline');6 const npmRunPath = require('npm-run-path');7 const isStream = require('is-stream');8 const _getStream = require('get-stream');9 const pFinally = require('p-finally');33 unmodified lines43 44 opts = Object.assign({45 maxBuffer: TEN_MEGABYTES,46 buffer: true,47- stripEof: true,47+ stripFinalNewline: true,48 preferLocal: true,49 localDir: parsed.options.cwd || process.cwd(),50 encoding: 'utf8',51 reject: true,52 cleanup: true53 }, parsed.options);54 55+ // TODO: Remove in the next major release56+ if (opts.stripEof === false) {57+ opts.stripFinalNewline = false;58+ }59+60 opts.stdio = stdio(opts);61 62 if (opts.preferLocal) {63 opts.env = npmRunPath.env(Object.assign({}, opts, {cwd: opts.localDir}));29 unmodified lines93 }94 }95 96 function handleOutput(opts, val) {92- if (val && opts.stripEof) {93- val = stripEof(val);97+ if (val && opts.stripFinalNewline) {98+ val = stripFinalNewline(val);99 }100 101 return val;102 }264 unmodified linesmodified:package.json+1 added-1 removed
41 unmodified lines4243444546464748495015 unmodified lines41 unmodified lines "is-stream": "^1.1.0", "npm-run-path": "^2.0.0", "p-finally": "^1.0.0", "signal-exit": "^3.0.0", "strip-eof": "^1.0.0" "strip-final-newline": "^2.0.0" }, "devDependencies": { "ava": "*", "cat-names": "^1.0.2",15 unmodified linesmodified:readme.md+2 added-2 removed
193 unmodified lines194 Default: `false`195 196 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.197 198-#### stripEof198+#### stripFinalNewline199 200 Type: `boolean`<br>201 Default: `true`202 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.204 205 #### preferLocal206 207 Type: `boolean`<br>120 unmodified linesmodified:test.js+6 added-1 removed
136 unmodified lines137 t.is(typeof err.stdout, 'string');138 t.is(typeof err.stderr, 'string');139 });140 141-test('stripEof option', async t => {141+test('stripEof option (legacy)', async t => {142 const {stdout} = await m('noop', ['foo'], {stripEof: false});143 t.is(stdout, 'foo\n');144 });145 146+test('stripFinalNewline option', async t => {147+ const {stdout} = await m('noop', ['foo'], {stripFinalNewline: false});148+ t.is(stdout, 'foo\n');149+});150+151 test.serial('preferLocal option', async t => {152 t.true((await m('cat-names')).stdout.length > 2);153 154 if (process.platform === 'win32') {394 unmodified lines