-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Support passing scoped package names to --scripts-version arg #826
Conversation
@@ -154,8 +154,8 @@ function getInstallPackage(version) { | |||
function getPackageName(installPackage) { | |||
if (~installPackage.indexOf('.tgz')) { |
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.
Can you please kill ~
on this line as well? It is the kind of "clever code" that is extremely confusing 😄 . I missed it when I reviewed the change adding it.
return installPackage.match(/^.+\/(.+)-.+\.tgz$/)[1]; | ||
} else if (~installPackage.indexOf('@')) { | ||
return installPackage.split('@')[0]; | ||
} else if (installPackage.indexOf('@') > 0) { |
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.
This needs a comment because somebody else might change it to -1
later without understanding the reason.
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.
Good point, will do.
@@ -152,10 +152,10 @@ function getInstallPackage(version) { | |||
|
|||
// Extract package name from tarball url or path. | |||
function getPackageName(installPackage) { | |||
if (~installPackage.indexOf('.tgz')) { | |||
if (installPackage.indexOf('.tgz') > 0) { |
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.
This might as well be > -1
because the intended meaning is regular "contains".
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.
Only reason I used > 0
here is because ".tgz" would be an invalid name that should not be split. But that's an edge case - cool with changing to > -1
.
Can you squash and rebase this? The commit log is getting confusing. You don't need to keep this up to date—I'll make sure to rebase/cherry-pick before merging. |
Sorry about that. Branch and commit log should be back to the original. |
Thanks! |
…ok#826) * Support passing scoped package names to --scripts-version arg * Factor out bitwise operator in indexOf test * Comment on stripping only version or tag from package name arg
…ok#826) * Support passing scoped package names to --scripts-version arg * Factor out bitwise operator in indexOf test * Comment on stripping only version or tag from package name arg
create-react-app myApp --scripts-version=@myscope/react-scripts
fails sincegetPackageName
currently assumes a match of "@" at any index denotes version and strips it from the str.Minor change to fix.