FIX #2719: enforce name argument of migration generate command#6690
Merged
pleerock merged 2 commits intotypeorm:masterfrom Sep 26, 2020
Merged
FIX #2719: enforce name argument of migration generate command#6690pleerock merged 2 commits intotypeorm:masterfrom
pleerock merged 2 commits intotypeorm:masterfrom
Conversation
added 2 commits
September 9, 2020 16:56
enforce the type of the name argument in order to return a more useful error message when the user forgets to provide a migration name to the generate migration command Closes: typeorm#2719, typeorm#4798, typeorm#4805
…ssing name argument enforce the type of the name argument in order to return a more useful error message when the user forgets to provide a migration name to the generate migration command Closes: typeorm#2719, typeorm#4798, typeorm#4805
nitaking
approved these changes
Sep 24, 2020
Member
|
Looks good, thank you for your contribution! |
zaro
pushed a commit
to zaro/typeorm
that referenced
this pull request
Jan 12, 2021
… (typeorm#6690) * fix: enforce name argument of migration generate command enforce the type of the name argument in order to return a more useful error message when the user forgets to provide a migration name to the generate migration command Closes: typeorm#2719, typeorm#4798, typeorm#4805 * fix: update error message text for generate migration command when missing name argument enforce the type of the name argument in order to return a more useful error message when the user forgets to provide a migration name to the generate migration command Closes: typeorm#2719, typeorm#4798, typeorm#4805 Co-authored-by: Akosua Asante <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User error sometimes leads to running the migration generate command with invalid parameters. If the
-nargument for the name of the migration class is completely missing, it returns a useful error to the user:However, if the user includes the
-nargument but forgets to pass in a value for that option, currently theyargslibrary is interpreting that as a positional argument, with a value oftrue(https://github.com/yargs/yargs/blob/master/docs/advanced.md#positional-arguments). This then results in the aforementionedTypeError: str.replace is not a functionerror whennameis passed into thecamelCasemethod.The goal of this PR is to improve the messaging returned to the user in this case; hopefully making it more obvious how to resolve.
Previous work was done in this area to return a message if the
nameargument is empty: e68538abut it doesn't work here because of the argument being coerced into a boolean value.
This PR adds the
type: "string"to thenameargument options passed toyarg. This tells theyarglibrary to treat this argument as a string at all times, and a missing value will be interpreted as an empty string, rather than a positional argument. With this PR we get the following:Note to maintainers: I am happy to add tests if wanted; but I wasn't able to find any existing tests for what's returned by the various CLI commands; and this was a fairly small change.
Closes (or at least, resolves the confusion brought up by): #2719, #4798, #4805