Skip to content
Myr

script.js

This file

Path

lib/methods/script.js

22 lines · 1015 bytes · JavaScript

Last changed by

Add more code comments (#984)ehmickybefore adoptionfdd8a9f

History of this file

Take it

Add more code comments (#984)ehmickybefore adoptionfdd8a9f

line 1why, one step back
1// Sets `$.sync` and `$.s`

Rename files (#977)ehmickybefore adoption4b2e316

lines 2–6why, one step back
2export const setScriptSync = (boundExeca, createNested, boundOptions) => {
3 boundExeca.sync = createNested(mapScriptSync, boundOptions);4 boundExeca.s = boundExeca.sync;5};6

Add more code comments (#984)ehmickybefore adoptionfdd8a9f

line 7why, one step back
7// Main logic for `$`

Rename files (#977)ehmickybefore adoption4b2e316

line 8why, one step back
8export const mapScriptAsync = ({options}) => getScriptOptions(options);

Add more code comments (#984)ehmickybefore adoptionfdd8a9f

lines 9–10why, one step back
9
10// Main logic for `$.sync`

Rename files (#977)ehmickybefore adoption4b2e316

lines 11–12why, one step back
11const mapScriptSync = ({options}) => ({...getScriptOptions(options), isSync: true});
12

Add more code comments (#984)ehmickybefore adoptionfdd8a9f

line 13why, one step back
13// `$` is like `execa` but with script-friendly options: `{stdin: 'inherit', preferLocal: true}`

Rename files (#977)ehmickybefore adoption4b2e316

lines 14–19why, one step back
14const getScriptOptions = options => ({options: {...getScriptStdinOption(options), ...options}});
1516const getScriptStdinOption = ({input, inputFile, stdio}) => input === undefined && inputFile === undefined && stdio === undefined17 ? {stdin: 'inherit'}18 : {};19

Add more code comments (#984)ehmickybefore adoptionfdd8a9f

lines 20–21why, one step back
20// 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.

Rename files (#977)ehmickybefore adoption4b2e316

line 22why, one step back
22export const deepScriptOptions = {preferLocal: true};