Skip to content
This repository was archived by the owner on Jan 26, 2019. It is now read-only.

Commit c5f5b00

Browse files
jihchigaearon
authored andcommitted
Fix using pre-release tags with a tarball url in --scripts-version (#876)
* Add supports for prelease tags version * Add comment to regex * Cut everything after the first -\d * Make semver version optional, so just package name get parsed correctly
1 parent 88c15d0 commit c5f5b00

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/create-react-app/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,9 @@ function getInstallPackage(version) {
153153
// Extract package name from tarball url or path.
154154
function getPackageName(installPackage) {
155155
if (installPackage.indexOf('.tgz') > -1) {
156-
return installPackage.match(/^.+\/(.+)-.+\.tgz$/)[1];
156+
// The package name could be with or without semver version, e.g. react-scripts-0.2.0-alpha.1.tgz
157+
// However, this function returns package name only wihout semver version.
158+
return installPackage.match(/^.+\/(.+?)(?:-\d+.+)?\.tgz$/)[1];
157159
} else if (installPackage.indexOf('@') > 0) {
158160
// Do not match @scope/ when stripping off @version or @tag
159161
return installPackage.charAt(0) + installPackage.substr(1).split('@')[0];

0 commit comments

Comments
 (0)