-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Add Input & Output check to CLI #17311
Conversation
Throw an error if the input and output file for the CLI are identical.
…les identical (along with ensuring path resolution)
Awesome, thank you so much 🙇 |
@@ -95,6 +95,15 @@ export async function handle(args: Result<ReturnType<typeof options>>) { | |||
} | |||
} | |||
|
|||
// Check if the input and output file paths are identical, otherwise return an | |||
// error to the user. | |||
if (args['--input'] === args['--output']) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before we merge this I want to check 1 small thing. Commenting here to prevent auto merge from happening.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So one edge case here is that -
can be used by both the --input
and --output
, e.g.: --input - --output -
. The -
means "use stdin and stdout respectively". In this case we don't want the error to show up.
Added a failing integration test + a fix for this.
(I also ran prettier in a separate commit)
Thanks you! These changes will be available in the next release. |
Throw an error if the input and output file for the CLI are identical.