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

Support passing scoped package names to --scripts-version arg #826

Merged
merged 3 commits into from
Oct 11, 2016
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/create-react-app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Contributor

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".

Copy link
Contributor Author

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.

return installPackage.match(/^.+\/(.+)-.+\.tgz$/)[1];
} else if (~installPackage.indexOf('@')) {
return installPackage.split('@')[0];
} else if (installPackage.indexOf('@') > 0) {
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, will do.

return installPackage.charAt(0) + installPackage.substr(1).split('@')[0];
}
return installPackage;
}
Expand Down