Skip to content
Myr

Replace `null` by `undefined` (#193)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by ehmicky · committed by Sindre Sorhus · parent 7f8d911 · Browse files · 7 files+32 added−34 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

7 files+32 added−34 removed

  • tests:+14 added−14 removed
  • other:+18 added−20 removed

7 files+32 added−34 removed

modified:lib/errname.js+2 added-2 removed
modified:lib/stdio.js+2 added-2 removed
modified:test/errname.js+1 added-1 removed
modified:test/stdio.js+13 added-13 removed
modified:index.js+9 added-9 removed
92 unmodified lines
93}9495function makeAllStream(spawned) {96 if (!spawned.stdout && !spawned.stderr) {97 return null;97 return;98 }99100 const mixed = mergeStream();101
9 unmodified lines
111}112113function getStream(process, stream, {encoding, buffer, maxBuffer}) {114 if (!process[stream]) {115 return null;115 return;116 }117118 let ret;119
40 unmodified lines
160 error.exitCodeName = exitCodeName;161 error.stdout = stdout;162 error.stderr = stderr;163 error.failed = true;164 // `signal` emitted on `spawned.on('exit')` event can be `null`. We normalize165 // it to `undefined`164 error.signal = signal || null;166 error.signal = signal || undefined;167 error.cmd = joinedCommand;168 error.timedOut = Boolean(timedOut);169170 if ('all' in result) {
67 unmodified lines
238 spawned.kill();239 });240 }241240 let timeoutId = null;242 let timeoutId;243 let timedOut = false;244245 const cleanup = () => {244 if (timeoutId) {246 if (timeoutId !== undefined) {247 clearTimeout(timeoutId);246 timeoutId = null;248 timeoutId = undefined;249 }250251 if (removeExitHandler) {252 removeExitHandler();
1 unmodified line
254 };255256 if (parsed.options.timeout > 0) {257 timeoutId = setTimeout(() => {256 timeoutId = null;258 timeoutId = undefined;259 timedOut = true;260 spawned.kill(parsed.options.killSignal);261 }, parsed.options.timeout);262 }
70 unmodified lines
333 exitCode: 0,334 exitCodeName: 'SUCCESS',335 failed: false,336 killed: false,335 signal: null,337 cmd: joinedCommand,338 timedOut: false339 };340 }), destroy);
60 unmodified lines
401 code: 0,402 exitCode: 0,403 exitCodeName: 'SUCCESS',404 failed: false,404 signal: null,405 cmd: joinedCommand,406 timedOut: false407 };408};
2 unmodified lines
modified:readme.md-2 removed
66 unmodified lines
67 stdout: '',68 stderr: '',69 all: '',70 failed: true,71 signal: null,71 cmd: 'exit 3',72 timedOut: false,73 killed: false74 }
14 unmodified lines
89 exitCodeName: 'ESRCH',90 stdout: '',91 stderr: '',92 failed: true,94 signal: null,93 cmd: 'exit 3',94 timedOut: false95 }96 */
244 unmodified lines
modified:test.js+5 added-5 removed
208 unmodified lines
209 const {stdout} = await execa('stdin', {210 input: 'hello',211 stdio: [null, 'ignore', null]212 });213 t.is(stdout, null);213 t.is(stdout, undefined);214});215216test('helpful error trying to provide an input stream in sync mode', t => {217 t.throws(
148 unmodified lines
366 t.is(error.signal, 'SIGHUP');367 });368}369370test('result.signal is null for successful execution', async t => {371 t.is((await execa('noop')).signal, null);370test('result.signal is undefined for successful execution', async t => {371 t.is((await execa('noop')).signal, undefined);372});373374test('result.signal is null if process failed, but was not killed', async t => {374test('result.signal is undefined if process failed, but was not killed', async t => {375 const error = await t.throwsAsync(execa('exit', [2]), {message: getExitRegExp('2')});376 t.is(error.signal, null);376 t.is(error.signal, undefined);377});378379async function code(t, num) {380 const error = await t.throwsAsync(execa('exit', [`${num}`]), {code: num, message: getExitRegExp(num)});
208 unmodified lines