Skip to content
Myr

sync.js

This file

Path

lib/stdio/sync.js

54 lines · 1.7 KiB · JavaScript

Last changed by

Add support for `std*: ['pipe', 'inherit']` with `execaSync()` (#954)ehmickybefore adoptionc15edbc

History of this file

Take it

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

Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09

lines 1–2why, one step back
1import {readFileSync} from 'node:fs';
2import {bufferToUint8Array} from './uint-array.js';

Use `async/await` instead of direct `Promise` manipulation (#659)ehmickybefore adoption7122767

lines 3–5why, one step back
3import {handleInput} from './handle.js';
4import {TYPE_TO_MESSAGE} from './type.js';5

Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09

line 6why, one step back
6// Normalize `input`, `inputFile`, `stdin`, `stdout` and `stderr` options, before spawning, in sync mode

Add support for `std*: ['pipe', 'inherit']` with `execaSync()` (#954)ehmickybefore adoptionc15edbc

line 7why, one step back
7export const handleInputSync = (options, verboseInfo) => handleInput(addPropertiesSync, options, verboseInfo, true);

Use `async/await` instead of direct `Promise` manipulation (#659)ehmickybefore adoption7122767

lines 8–9why, one step back
8
9const forbiddenIfSync = ({type, optionName}) => {

Improve validation of `execaSync()` options (#940)ehmickybefore adoptionf6e1ac1

line 10why, one step back
10 throwInvalidSyncValue(optionName, TYPE_TO_MESSAGE[type]);

Use `async/await` instead of direct `Promise` manipulation (#659)ehmickybefore adoption7122767

lines 11–12why, one step back
11};
12

Improve validation of `execaSync()` options (#940)ehmickybefore adoptionf6e1ac1

line 13why, one step back
13const forbiddenNativeIfSync = ({optionName, value}) => {

Do not allow `overlapped` with `execaSync()` (#949)ehmickybefore adoption7c2f575

line 14why, one step back
14 if (value === 'ipc' || value === 'overlapped') {

Improve validation of `execaSync()` options (#940)ehmickybefore adoptionf6e1ac1

lines 15–21why, one step back
15 throwInvalidSyncValue(optionName, `"${value}"`);
16 }1718 return {};19};2021const throwInvalidSyncValue = (optionName, value) => {

Improve validation of `execaSync()` `stdio` option (#941)ehmickybefore adoptioncc565f9

line 22why, one step back
22 throw new TypeError(`The \`${optionName}\` option cannot be ${value} with synchronous methods.`);

Improve validation of `execaSync()` options (#940)ehmickybefore adoptionf6e1ac1

lines 23–24why, one step back
23};
24

Refactor tests (#934)ehmickybefore adoption52c4bde

line 25why, one step back
25const addProperties = {

Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09

lines 26–27why, one step back
26 generator() {},
27 asyncGenerator: forbiddenIfSync,

Refactor tests (#934)ehmickybefore adoption52c4bde

lines 28–29why, one step back
28 webStream: forbiddenIfSync,
29 nodeStream: forbiddenIfSync,

Add support for `std*: TransformStream` option (#938)ehmickybefore adoption45824d6

line 30why, one step back
30 webTransform: forbiddenIfSync,

Add support for `std*: duplex` option (#937)ehmickybefore adoption6ca44fb

line 31why, one step back
31 duplex: forbiddenIfSync,

Add support for sync iterables with `execaSync()` (#944)ehmickybefore adoptionf744f7d

line 32why, one step back
32 asyncIterable: forbiddenIfSync,

Improve validation of `execaSync()` options (#940)ehmickybefore adoptionf6e1ac1

line 33why, one step back
33 native: forbiddenNativeIfSync,

Refactor tests (#934)ehmickybefore adoption52c4bde

lines 34–35why, one step back
34};
35

Use `async/await` instead of direct `Promise` manipulation (#659)ehmickybefore adoption7122767

lines 36–37why, one step back
36const addPropertiesSync = {
37 input: {

Refactor tests (#934)ehmickybefore adoption52c4bde

line 38why, one step back
38 ...addProperties,

Add support for sync iterables with `execaSync()` (#944)ehmickybefore adoptionf744f7d

lines 39–43why, one step back
39 fileUrl: ({value}) => ({contents: [bufferToUint8Array(readFileSync(value))]}),
40 filePath: ({value: {file}}) => ({contents: [bufferToUint8Array(readFileSync(file))]}),41 iterable: ({value}) => ({contents: [...value]}),42 string: ({value}) => ({contents: [value]}),43 uint8Array: ({value}) => ({contents: [value]}),

Use `async/await` instead of direct `Promise` manipulation (#659)ehmickybefore adoption7122767

lines 44–45why, one step back
44 },
45 output: {

Refactor tests (#934)ehmickybefore adoption52c4bde

line 46why, one step back
46 ...addProperties,

Refactor `stdio` option (#927)ehmickybefore adoptionc9cdd2d

lines 47–48why, one step back
47 fileUrl: ({value}) => ({path: value}),
48 filePath: ({value: {file}}) => ({path: file}),

Add support for `std*: ['pipe', 'inherit']` with `execaSync()` (#954)ehmickybefore adoptionc15edbc

line 49why, one step back
49 fileNumber: ({value}) => ({path: value}),

Add support for sync iterables with `execaSync()` (#944)ehmickybefore adoptionf744f7d

line 50why, one step back
50 iterable: forbiddenIfSync,

Refactor `stdio` option (#927)ehmickybefore adoptionc9cdd2d

line 51why, one step back
51 string: forbiddenIfSync,

Allow `stdin: uint8Array` option (#670)ehmickybefore adoption2ac81d4

line 52why, one step back
52 uint8Array: forbiddenIfSync,

Use `async/await` instead of direct `Promise` manipulation (#659)ehmickybefore adoption7122767

lines 53–54why, one step back
53 },
54};