2 const alias = ['stdin', 'stdout', 'stderr'];
4 const hasAlias = opts => alias.some(x => Boolean(opts[x]));
6 module.exports = opts => {
11 if (opts.stdio && hasAlias(opts)) {
12 throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${alias.map(x => `\`${x}\``).join(', ')}`);
15 if (typeof opts.stdio === 'string') {
19 const stdio = opts.stdio || [];
21 if (!Array.isArray(stdio)) {
22 throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof stdio}\``);
26 const len = Math.max(stdio.length, alias.length);
28 for (let i = 0; i < len; i++) {
31 if (stdio[i] !== undefined) {
33 } else if (opts[alias[i]] !== undefined) {
34 value = opts[alias[i]];