Skip to content
Myr

input.js

This file

Path

lib/stdio/input.js

50 lines · 1.3 KiB · JavaScript

Last changed by

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

History of this file

Take it

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

Validate `input` option's type (#668)ehmickybefore adoption65742c6

line 1why, one step back
1import {isReadableStream} from 'is-stream';

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

line 2why, one step back
2import {isUint8Array} from './uint-array.js';

Improve syntax of `std*: filePath` option (#671)ehmickybefore adoption90e0e13

line 3why, one step back
3import {isUrl, isFilePathString} from './type.js';

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

line 4why, one step back
4

Allow using the `input`, `inputFile` and `stdin` options together (#666)ehmickybefore adoptionbeabd25

line 5why, one step back
5// Append the `stdin` option with the `input` and `inputFile` options

Refactor `stdio` option (#927)ehmickybefore adoptionc9cdd2d

lines 6–11why, one step back
6export const handleInputOptions = ({input, inputFile}, fdNumber) => fdNumber === 0
7 ? [8 ...handleInputOption(input),9 ...handleInputFileOption(inputFile),10 ]11 : [];

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

line 12why, one step back
12

Refactor `stdio` option (#927)ehmickybefore adoptionc9cdd2d

line 13why, one step back
13const handleInputOption = input => input === undefined ? [] : [{

Improve syntax of `std*: filePath` option (#671)ehmickybefore adoption90e0e13

line 14why, one step back
14 type: getInputType(input),

Allow using the `input`, `inputFile` and `stdin` options together (#666)ehmickybefore adoptionbeabd25

lines 15–16why, one step back
15 value: input,
16 optionName: 'input',

Refactor `stdio` option (#927)ehmickybefore adoptionc9cdd2d

line 17why, one step back
17}];

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

line 18why, one step back
18

Improve syntax of `std*: filePath` option (#671)ehmickybefore adoption90e0e13

line 19why, one step back
19const getInputType = input => {

Upgrade `is-stream` to `4.0.1` (#835)ehmickybefore adoption9cd62aa

line 20why, one step back
20 if (isReadableStream(input, {checkOpen: false})) {

Validate `input` option's type (#668)ehmickybefore adoption65742c6

lines 21–27why, one step back
21 return 'nodeStream';
22 }2324 if (typeof input === 'string') {25 return 'string';26 }27

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

line 28why, one step back
28 if (isUint8Array(input)) {

Validate `input` option's type (#668)ehmickybefore adoption65742c6

lines 29–34why, one step back
29 return 'uint8Array';
30 }3132 throw new Error('The `input` option must be a string, a Uint8Array or a Node.js Readable stream.');33};34

Refactor `stdio` option (#927)ehmickybefore adoptionc9cdd2d

line 35why, one step back
35const handleInputFileOption = inputFile => inputFile === undefined ? [] : [{

Improve syntax of `std*: filePath` option (#671)ehmickybefore adoption90e0e13

line 36why, one step back
36 ...getInputFileType(inputFile),

Allow using the `input`, `inputFile` and `stdin` options together (#666)ehmickybefore adoptionbeabd25

line 37why, one step back
37 optionName: 'inputFile',

Refactor `stdio` option (#927)ehmickybefore adoptionc9cdd2d

line 38why, one step back
38}];

Improve syntax of `std*: filePath` option (#671)ehmickybefore adoption90e0e13

lines 39–49why, one step back
39
40const getInputFileType = inputFile => {41 if (isUrl(inputFile)) {42 return {type: 'fileUrl', value: inputFile};43 }4445 if (isFilePathString(inputFile)) {46 return {type: 'filePath', value: {file: inputFile}};47 }4849 throw new Error('The `inputFile` option must be a file path string or a file URL.');

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

line 50why, one step back
50};