Skip to content
Myr

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

4 files+18 added−8 removed

modified:index.js+9 added-4 removed
1'use strict';2const path = require('path');3const childProcess = require('child_process');4const crossSpawn = require('cross-spawn');5const stripEof = require('strip-eof');5const stripFinalNewline = require('strip-final-newline');6const npmRunPath = require('npm-run-path');7const isStream = require('is-stream');8const _getStream = require('get-stream');9const pFinally = require('p-finally');
33 unmodified lines
4344 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);5455 // TODO: Remove in the next major release56 if (opts.stripEof === false) {57 opts.stripFinalNewline = false;58 }5960 opts.stdio = stdio(opts);6162 if (opts.preferLocal) {63 opts.env = npmRunPath.env(Object.assign({}, opts, {cwd: opts.localDir}));
29 unmodified lines
93 }94}9596function handleOutput(opts, val) {92 if (val && opts.stripEof) {93 val = stripEof(val);97 if (val && opts.stripFinalNewline) {98 val = stripFinalNewline(val);99 }100101 return val;102}
264 unmodified lines
modified:package.json+1 added-1 removed
modified:readme.md+2 added-2 removed
193 unmodified lines
194Default: `false`195196If `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.197198#### stripEof198#### stripFinalNewline199200Type: `boolean`<br>201Default: `true`202203[Strip EOF](https://github.com/sindresorhus/strip-eof) (last newline) from the output.203Strip the final [newline character](https://en.wikipedia.org/wiki/Newline) from the output.204205#### preferLocal206207Type: `boolean`<br>
120 unmodified lines
modified:test.js+6 added-1 removed
136 unmodified lines
137 t.is(typeof err.stdout, 'string');138 t.is(typeof err.stderr, 'string');139});140141test('stripEof option', async t => {141test('stripEof option (legacy)', async t => {142 const {stdout} = await m('noop', ['foo'], {stripEof: false});143 t.is(stdout, 'foo\n');144});145146test('stripFinalNewline option', async t => {147 const {stdout} = await m('noop', ['foo'], {stripFinalNewline: false});148 t.is(stdout, 'foo\n');149});150151test.serial('preferLocal option', async t => {152 t.true((await m('cat-names')).stdout.length > 2);153154 if (process.platform === 'win32') {
394 unmodified lines