script.js
This file
Path
lib/methods/script.js
22 lines · 1.0 KiB · JavaScript
Last changed by
Harden some thingsSindre Sorhusbefore adoption4a0a121
History of this fileTake it
The walk stopped after 200 commits: lines older than c8a6ed7 point at it.
Improve documentation (#1003)ehmickybefore adoptionc8a6ed7
lines 1–13why, one step back1// Sets `$.sync` and `$.s`2export const setScriptSync = (boundExeca, createNested, boundOptions) => {3 boundExeca.sync = createNested(mapScriptSync, boundOptions);4 boundExeca.s = boundExeca.sync;5};67// Main logic for `$`8export const mapScriptAsync = ({options}) => getScriptOptions(options);910// Main logic for `$.sync`11const mapScriptSync = ({options}) => ({...getScriptOptions(options), isSync: true});1213// `$` is like `execa` but with script-friendly options: `{stdin: 'inherit', preferLocal: true}`Harden some thingsSindre Sorhusbefore adoption4a0a121
line 14why, one step back14const getScriptOptions = options => ({options: {__proto__: null, ...getScriptStdinOption(options), ...options}});Improve documentation (#1003)ehmickybefore adoptionc8a6ed7
lines 15–22why, one step back1516const getScriptStdinOption = ({input, inputFile, stdio}) => input === undefined && inputFile === undefined && stdio === undefined17 ? {stdin: 'inherit'}18 : {};1920// When using $(...).pipe(...), most script-friendly options should apply to both commands.21// However, some options (like `stdin: 'inherit'`) would create issues with piping, i.e. cannot be deep.22export const deepScriptOptions = {preferLocal: true};