Skip to content

Commit 819f97a

Browse files
jihchifeiqitian
authored andcommitted
Fix using pre-release tags with a tarball url in --scripts-version (facebook#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 cf4b5e3 commit 819f97a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/create-react-app/index.js

Lines changed: 3 additions & 1 deletion
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)