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

Conversation

pdillon
Copy link
Contributor

@pdillon pdillon commented Oct 3, 2016

create-react-app myApp --scripts-version=@myscope/react-scripts fails since getPackageName currently assumes a match of "@" at any index denotes version and strips it from the str.
Minor change to fix.

@@ -154,8 +154,8 @@ function getInstallPackage(version) {
function getPackageName(installPackage) {
if (~installPackage.indexOf('.tgz')) {
Copy link
Contributor

@gaearon gaearon Oct 3, 2016

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.

@gaearon gaearon added this to the 0.7.0 milestone Oct 3, 2016
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.

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

@gaearon
Copy link
Contributor

gaearon commented Oct 7, 2016

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.

@pdillon
Copy link
Contributor Author

pdillon commented Oct 7, 2016

Sorry about that. Branch and commit log should be back to the original.

@gaearon gaearon merged commit 1359cc4 into facebook:master Oct 11, 2016
@gaearon
Copy link
Contributor

gaearon commented Oct 11, 2016

Thanks!

@pdillon pdillon deleted the master branch October 12, 2016 03:27
feiqitian pushed a commit to feiqitian/create-react-app that referenced this pull request Oct 25, 2016
…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
jarlef pushed a commit to jarlef/create-react-app that referenced this pull request Nov 28, 2016
…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
@lock lock bot locked and limited conversation to collaborators Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants