Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split input/inputFile options to their own file #629

Merged
merged 1 commit into from
Dec 21, 2023
Merged

Conversation

ehmicky
Copy link
Collaborator

@ehmicky ehmicky commented Dec 21, 2023

This is small refactoring splitting the logic for the input and inputFile options to its own file.

@@ -69,7 +24,6 @@ const handleInputFileOption = (stdioStream, index, inputFile, input) => {

const optionName = 'inputFile';
validateInputOption(stdioStream.value, optionName);
validateRegularUrl(inputFile, optionName);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now handled by the validateFileStdio() method above, which has been slightly reworked.

@@ -29,7 +29,8 @@ export const isRegularUrl = stdioOption => isUrlInstance(stdioOption) && !hasFil

const stringIsFilePath = stdioOption => stdioOption.startsWith('.') || isAbsolute(stdioOption);
const isFilePath = stdioOption => typeof stdioOption === 'string' && stringIsFilePath(stdioOption);
export const isUnknownStdioString = stdioOption => typeof stdioOption === 'string' && !stringIsFilePath(stdioOption) && !KNOWN_STDIO_STRINGS.has(stdioOption);

export const isUnknownStdioString = (type, stdioOption) => type === 'native' && typeof stdioOption === 'string' && !KNOWN_STDIO_STRINGS.has(stdioOption);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

native type is when the stdin/stdout/stderr value is passed directly to child_process.spawn(), as opposed to being handled by Execa. In that case, only few specific strings are allowed.

@sindresorhus sindresorhus merged commit 0b8e297 into main Dec 21, 2023
14 checks passed
@sindresorhus sindresorhus deleted the split-source branch December 21, 2023 03:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants