Skip to content
Myr

Do not allow returning `null` from transforms (#737)

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

authored by ehmicky · committed by GitHub · parent 85a5882 · Browse files · 2 files+31 added−15 removed
This commit

State

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

Diff stats

2 files+31 added−15 removed

  • tests:+18 added−12 removed
  • other:+13 added−3 removed

2 files+31 added−15 removed

modified:lib/stdio/generator.js+13 added-3 removed
modified:test/stdio/generator.js+18 added-12 removed
77 unmodified lines
7879test('Can use generators with childProcess.stdio[*] as input', testGeneratorStdioInputPipe, false);80test('Can use generators with childProcess.stdio[*] as input, objectMode', testGeneratorStdioInputPipe, true);8182const testGeneratorReturn = async (t, index, generators, fixtureName) => {83 await t.throwsAsync(84 execa(fixtureName, [`${index}`], getStdio(index, generators)),85 {message: /a string or an Uint8Array/},86 );82// eslint-disable-next-line max-params83const testGeneratorReturn = async (t, index, generators, fixtureName, isNull) => {84 const childProcess = execa(fixtureName, [`${index}`], getStdio(index, generators));85 const message = isNull ? /not return null/ : /a string or an Uint8Array/;86 await t.throwsAsync(childProcess, {message});87};8889const inputObjectGenerators = [foobarUint8Array, getOutputGenerator(foobarObject, false), serializeGenerator];90const lastInputObjectGenerators = [foobarUint8Array, getOutputGenerator(foobarObject, true)];91const invalidOutputObjectGenerator = getOutputGenerator(foobarObject, false);92const inputNullGenerator = objectMode => [foobarUint8Array, getOutputGenerator(null, objectMode), serializeGenerator];93const outputNullGenerator = objectMode => getOutputGenerator(null, objectMode);9493test('Generators with result.stdin cannot return an object if not in objectMode', testGeneratorReturn, 0, inputObjectGenerators, 'stdin-fd.js');94test('Generators with result.stdio[*] as input cannot return an object if not in objectMode', testGeneratorReturn, 3, inputObjectGenerators, 'stdin-fd.js');95test('The last generator with result.stdin cannot return an object even in objectMode', testGeneratorReturn, 0, lastInputObjectGenerators, 'stdin-fd.js');96test('The last generator with result.stdio[*] as input cannot return an object even in objectMode', testGeneratorReturn, 3, lastInputObjectGenerators, 'stdin-fd.js');97test('Generators with result.stdout cannot return an object if not in objectMode', testGeneratorReturn, 1, invalidOutputObjectGenerator, 'noop-fd.js');98test('Generators with result.stderr cannot return an object if not in objectMode', testGeneratorReturn, 2, invalidOutputObjectGenerator, 'noop-fd.js');99test('Generators with result.stdio[*] as output cannot return an object if not in objectMode', testGeneratorReturn, 3, invalidOutputObjectGenerator, 'noop-fd.js');95test('Generators with result.stdin cannot return an object if not in objectMode', testGeneratorReturn, 0, inputObjectGenerators, 'stdin-fd.js', false);96test('Generators with result.stdio[*] as input cannot return an object if not in objectMode', testGeneratorReturn, 3, inputObjectGenerators, 'stdin-fd.js', false);97test('The last generator with result.stdin cannot return an object even in objectMode', testGeneratorReturn, 0, lastInputObjectGenerators, 'stdin-fd.js', false);98test('The last generator with result.stdio[*] as input cannot return an object even in objectMode', testGeneratorReturn, 3, lastInputObjectGenerators, 'stdin-fd.js', false);99test('Generators with result.stdout cannot return an object if not in objectMode', testGeneratorReturn, 1, invalidOutputObjectGenerator, 'noop-fd.js', false);100test('Generators with result.stderr cannot return an object if not in objectMode', testGeneratorReturn, 2, invalidOutputObjectGenerator, 'noop-fd.js', false);101test('Generators with result.stdio[*] as output cannot return an object if not in objectMode', testGeneratorReturn, 3, invalidOutputObjectGenerator, 'noop-fd.js', false);102test('Generators with result.stdin cannot return null if not in objectMode', testGeneratorReturn, 0, inputNullGenerator(false), 'stdin-fd.js', false);103test('Generators with result.stdin cannot return null if in objectMode', testGeneratorReturn, 0, inputNullGenerator(true), 'stdin-fd.js', true);104test('Generators with result.stdout cannot return null if not in objectMode', testGeneratorReturn, 1, outputNullGenerator(false), 'noop-fd.js', false);105test('Generators with result.stdout cannot return null if in objectMode', testGeneratorReturn, 1, outputNullGenerator(true), 'noop-fd.js', true);106107// eslint-disable-next-line max-params108const testGeneratorOutput = async (t, index, reject, useShortcutProperty, objectMode) => {109 const {generator, output} = getOutputObjectMode(objectMode);
550 unmodified lines