-
Notifications
You must be signed in to change notification settings - Fork 12k
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
fix(new): improve error message when project name does not match regex #3902
Conversation
It'll be nice to be able to point to the part of the name that is causing the error. For example:
|
@baruchvlz I agree that that would be a nice addition. I've been looking for a way to determine at which position a regex fails, but I can't seem to find an easy way. Any suggestions? |
@beeman I'm thinking maybe we can use Something like so: var string = 'alpha-bravo-2';
string.indexOf(/[0-9]/.exec(string)); // 12 Obviously the RegExp will be more complex than this, but it's just an example. What do you think? |
@baruchvlz I've been trying to get the index of the failing char but I'm not sure, it looks like Here is the playground I set up using the RegExp from the project: https://jsbin.com/yokerac/1/edit?js,console |
@baruchvlz I've added an indicator that shows where the package name fails: Thanks to @delasteve for helping me with the method that finds the position. |
@beeman this is pretty useful! |
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.
The only thing missing would be a test. An acceptance test should be enough. See here for the current suite:
https://github.com/angular/angular-cli/blob/master/tests/acceptance/new.spec.ts
Thanks for reviewing @filipesilva! I've been looking at the current acceptance test, but the only seem to validate the RegExp, which did not change in this PR. https://github.com/angular/angular-cli/blob/master/tests/acceptance/new.spec.ts#L58-L83 The only thing that's enhanced is the error message. |
@beeman a test making sure that the message is correct, and that it shows the error in the right place, is what I was thinking about. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This fixes issue #3816 by making the error message explain better what the restrictions are:
Open to any suggestions to improve the language.