Skip to content
Myr

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 file

Take it

The walk stopped after 200 commits: lines older than ceb1069 point at it.

Re-order sections in API reference (#994)ehmickybefore adoptionceb1069

lines 1–13why, one step back
1// 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 back
14const getScriptOptions = options => ({options: {__proto__: null, ...getScriptStdinOption(options), ...options}});

Re-order sections in API reference (#994)ehmickybefore adoptionceb1069

lines 15–22why, one step back
15
16const 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};