Fix lint issues
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Sindre Sorhus · committed by Sindre Sorhus · parent f8397ba · Browse files · 4 files·+81 added−92 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+81 added−92 removed
- other:+81 added−92 removed
Provenance
- Commit
b7752fb- Tree
5cba75e- Author
Sindre Sorhus <sindresorhus@gmail.com>- Committer
Sindre Sorhus <sindresorhus@gmail.com>- Parent
f8397ba
4 files changed+81 added−92 removed
modified:lib/errname.js+2 added-2 removed
12 unmodified lines13141516171817181920212217 unmodified lines12 unmodified lines
if (typeof uv.errname !== 'function') { throw new TypeError('uv.errname is not a function'); } } catch (err) { console.error('execa/lib/errname: unable to establish process.binding(\'uv\')', err); } catch (error) { console.error('execa/lib/errname: unable to establish process.binding(\'uv\')', error); uv = null; }
module.exports = code => errname(uv, code);17 unmodified linesmodified:index.js+29 added-29 removed
143 unmodified lines144 } else {145 ret = _getStream.buffer(process[stream], {maxBuffer});146 }147 148- return ret.catch(err => {149- err.stream = stream;150- err.message = `${stream} ${err.message}`;151- throw err;148+ return ret.catch(error => {149+ error.stream = stream;150+ error.message = `${stream} ${error.message}`;151+ throw error;152 });153 }154 155 function makeError(result, options) {156 const {stdout, stderr} = result;157 158- let err = result.error;158+ let {error} = result;159 const {code, signal} = result;160 161 const {parsed, joinedCmd} = options;162 const timedOut = options.timedOut || false;163 164- if (!err) {164+ if (!error) {165 let output = '';166 167 if (Array.isArray(parsed.opts.stdio)) {168 if (parsed.opts.stdio[2] !== 'inherit') {6 unmodified lines175 } else if (parsed.opts.stdio !== 'inherit') {176 output = `\n${stderr}${stdout}`;177 }178 179- err = new Error(`Command failed: ${joinedCmd}${output}`);180- err.code = code < 0 ? errname(code) : code;179+ error = new Error(`Command failed: ${joinedCmd}${output}`);180+ error.code = code < 0 ? errname(code) : code;181 }182 183- err.stdout = stdout;184- err.stderr = stderr;185- err.failed = true;186- err.signal = signal || null;187- err.cmd = joinedCmd;188- err.timedOut = timedOut;183+ error.stdout = stdout;184+ error.stderr = stderr;185+ error.failed = true;186+ error.signal = signal || null;187+ error.cmd = joinedCmd;188+ error.timedOut = timedOut;189 190- return err;190+ return error;191 }192 193 function joinCmd(cmd, args) {194 let joinedCmd = cmd;12 unmodified lines207 208 let spawned;209 try {210 spawned = childProcess.spawn(parsed.cmd, parsed.args, parsed.opts);211- } catch (err) {212- return Promise.reject(err);211+ } catch (error) {212+ return Promise.reject(error);213 }214 215 let removeExitHandler;216 if (parsed.opts.cleanup) {29 unmodified lines246 cleanup();247 resolve({code, signal});248 });249 250- spawned.on('error', err => {250+ spawned.on('error', error => {251 cleanup();252- resolve({error: err});252+ resolve({error});253 });254 255 if (spawned.stdin) {256- spawned.stdin.on('error', err => {256+ spawned.stdin.on('error', error => {257 cleanup();258- resolve({error: err});258+ resolve({error});259 });260 }261 });262 16 unmodified lines279 result.stdout = arr[1];280 result.stderr = arr[2];281 282 if (result.error || result.code !== 0 || result.signal !== null) {283- const err = makeError(result, {283+ const error = makeError(result, {284 joinedCmd,285 parsed,286 timedOut287 });288 289 // TODO: missing some timeout logic for killed290 // https://github.com/nodejs/node/blob/master/lib/child_process.js#L203291- // err.killed = spawned.killed || killed;292- err.killed = err.killed || spawned.killed;291+ // error.killed = spawned.killed || killed;292+ error.killed = error.killed || spawned.killed;293 294 if (!parsed.opts.reject) {295- return err;295+ return error;296 }297 298- throw err;298+ throw error;299 }300 301 return {302 stdout: handleOutput(parsed.opts, result.stdout),36 unmodified lines339 const result = childProcess.spawnSync(parsed.cmd, parsed.args, parsed.opts);340 result.code = result.status;341 342 if (result.error || result.status !== 0 || result.signal !== null) {343- const err = makeError(result, {343+ const error = makeError(result, {344 joinedCmd,345 parsed346 });347 348 if (!parsed.opts.reject) {349- return err;349+ return error;350 }351 352- throw err;352+ throw error;353 }354 355 return {356 stdout: handleOutput(parsed.opts, result.stdout),10 unmodified linesmodified:package.json+2 added-2 removed
44 unmodified lines4546474849495051525354555656575859605 unmodified lines44 unmodified lines "signal-exit": "^3.0.0", "strip-final-newline": "^2.0.0" }, "devDependencies": { "ava": "*", "ava": "^0.25.0", "cat-names": "^1.0.2", "coveralls": "^3.0.1", "delay": "^3.0.0", "is-running": "^2.0.0", "nyc": "^13.0.1", "tempfile": "^2.0.0", "xo": "*" "xo": "^0.23.0" }, "nyc": { "exclude": [ "**/fixtures/**",5 unmodified linesmodified:test.js+48 added-59 removed
260 unmodified lines261 t.is(stderr, '.........\n');262 });263 264 test('skip throwing when using reject option', async t => {265- const err = await m('exit', ['2'], {reject: false});266- t.is(typeof err.stdout, 'string');267- t.is(typeof err.stderr, 'string');265+ const error = await m('exit', ['2'], {reject: false});266+ t.is(typeof error.stdout, 'string');267+ t.is(typeof error.stderr, 'string');268 });269 270 test('execa() returns code and failed properties', async t => {271 const {code, failed} = await m('noop', ['foo']);272- const err = await t.throws(m('exit', ['2']));272+ const error = await t.throws(m('exit', ['2']));273 t.is(code, 0);274 t.false(failed);275- t.is(err.code, 2);276- t.true(err.failed);275+ t.is(error.code, 2);276+ t.true(error.failed);277 });278 279-test(`use relative path with '..' chars`, async t => {279+test('use relative path with \'..\' chars', async t => {280 const pathViaParentDir = path.join('..', path.basename(__dirname), 'fixtures', 'noop');281 const {stdout} = await m(pathViaParentDir, ['foo']);282 t.is(stdout, 'foo');283 });4 unmodified lines288 await t.throws(cp);289 });290 }291 292-test('err.killed is true if process was killed directly', async t => {292+test('error.killed is true if process was killed directly', async t => {293 const cp = m('forever');294 295 setTimeout(() => {296 cp.kill();297 }, 100);298 299- const err = await t.throws(cp);300-301- t.true(err.killed);299+ const error = await t.throws(cp);300+ t.true(error.killed);301 });302 303 // TODO: Should this really be the case, or should we improve on child_process?305-test('err.killed is false if process was killed indirectly', async t => {304+test('error.killed is false if process was killed indirectly', async t => {305 const cp = m('forever');306 307 setTimeout(() => {308 process.kill(cp.pid, 'SIGINT');309 }, 100);310 312- const err = await t.throws(cp);313-314- t.false(err.killed);311+ const error = await t.throws(cp);312+ t.false(error.killed);313 });314 315 if (process.platform === 'darwin') {316 test.cb('sanity check: child_process.exec also has killed.false if killed indirectly', t => {319- const cp = childProcess.exec('forever', err => {320- t.truthy(err);321- t.false(err.killed);317+ const cp = childProcess.exec('forever', error => {318+ t.truthy(error);319+ t.false(error.killed);320 t.end();321 });322 323 setTimeout(() => {2 unmodified lines326 });327 }328 329 if (process.platform !== 'win32') {332- test('err.signal is SIGINT', async t => {330+ test('error.signal is SIGINT', async t => {331 const cp = m('forever');332 333 setTimeout(() => {334 process.kill(cp.pid, 'SIGINT');335 }, 100);336 339- const err = await t.throws(cp);340-341- t.is(err.signal, 'SIGINT');337+ const error = await t.throws(cp);338+ t.is(error.signal, 'SIGINT');339 });340 344- test('err.signal is SIGTERM', async t => {341+ test('error.signal is SIGTERM', async t => {342 const cp = m('forever');343 344 setTimeout(() => {345 process.kill(cp.pid, 'SIGTERM');346 }, 100);347 351- const err = await t.throws(cp);352-353- t.is(err.signal, 'SIGTERM');348+ const error = await t.throws(cp);349+ t.is(error.signal, 'SIGTERM');350 });351 356- test('custom err.signal', async t => {357- const err = await t.throws(m('delay', ['3000', '0'], {killSignal: 'SIGHUP', timeout: 1500}));358-359- t.is(err.signal, 'SIGHUP');352+ test('custom error.signal', async t => {353+ const error = await t.throws(m('delay', ['3000', '0'], {killSignal: 'SIGHUP', timeout: 1500}));354+ t.is(error.signal, 'SIGHUP');355 });356 }357 358 test('result.signal is null for successful execution', async t => {359 t.is((await m('noop')).signal, null);360 });361 362 test('result.signal is null if process failed, but was not killed', async t => {368- const err = await t.throws(m('exit', [2]));369- t.is(err.signal, null);363+ const error = await t.throws(m('exit', [2]));364+ t.is(error.signal, null);365 });366 367 async function code(t, num) {373- const err = await t.throws(m('exit', [`${num}`]));374-375- t.is(err.code, num);368+ const error = await t.throws(m('exit', [`${num}`]));369+ t.is(error.code, num);370 }371 378-test('err.code is 2', code, 2);379-test('err.code is 3', code, 3);380-test('err.code is 4', code, 4);372+test('error.code is 2', code, 2);373+test('error.code is 3', code, 3);374+test('error.code is 4', code, 4);375 376 test('timeout will kill the process early', async t => {383- const err = await t.throws(m('delay', ['60000', '0'], {timeout: 1500}));377+ const error = await t.throws(m('delay', ['60000', '0'], {timeout: 1500}));378 385- t.true(err.timedOut);386- t.not(err.code, 22);379+ t.true(error.timedOut);380+ t.not(error.code, 22);381 });382 383 test('timeout will not kill the process early', async t => {390- const err = await t.throws(m('delay', ['3000', '22'], {timeout: 30000}));384+ const error = await t.throws(m('delay', ['3000', '22'], {timeout: 30000}));385 392- t.false(err.timedOut);393- t.is(err.code, 22);386+ t.false(error.timedOut);387+ t.is(error.code, 22);388 });389 390 test('timedOut will be false if no timeout was set and zero exit code', async t => {391 const result = await m('delay', ['1000', '0']);398-392 t.false(result.timedOut);393 });394 395 test('timedOut will be false if no timeout was set and non-zero exit code', async t => {403- const err = await t.throws(m('delay', ['1000', '3']));404-405- t.false(err.timedOut);396+ const error = await t.throws(m('delay', ['1000', '3']));397+ t.false(error.timedOut);398 });399 400 async function errorMessage(t, expected, ...args) {409- const err = await t.throws(m('exit', args));410-411- t.regex(err.message, expected);401+ const error = await t.throws(m('exit', args));402+ t.regex(error.message, expected);403 }404 414-errorMessage.title = (message, expected) => `err.message matches: ${expected}`;405+errorMessage.title = (message, expected) => `error.message matches: ${expected}`;406 407 test(errorMessage, /Command failed: exit 2 foo bar/, 2, 'foo', 'bar');408 test(errorMessage, /Command failed: exit 3 baz quz/, 3, 'baz', 'quz');409 410 async function cmd(t, expected, ...args) {420- const err = await t.throws(m('fail', args));411+ const error = await t.throws(m('fail', args));412+ t.is(error.cmd, `fail${expected}`);413 422- t.is(err.cmd, `fail${expected}`);423-414 const result = await m('noop', args);425-415 t.is(result.cmd, `noop${expected}`);416 }417 418 cmd.title = (message, expected) => `cmd is: ${JSON.stringify(expected)}`;50 unmodified lines469 // Sometimes process can manage to accept input before exiting470 try {471 await m(`fast-exit-${process.platform}`, [], {input: 'data'});472 t.pass();484- } catch (err) {485- t.is(err.code, 'EPIPE');473+ } catch (error) {474+ t.is(error.code, 'EPIPE');475 }476 });477 }478 52 unmodified lines531 child.on('error', reject);532 child.on('exit', resolve);533 });534 546- const included = ee.listeners('exit').indexOf(listener) !== -1;535+ const included = ee.listeners('exit').includes(listener);536 t.false(included);537 });