Commit c5f5b006 authored by Jih-Chi Lee's avatar Jih-Chi Lee Committed by Dan Abramov
Browse files

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
parent 88c15d09
No related merge requests found
Showing with 3 additions and 1 deletion
+3 -1
......@@ -153,7 +153,9 @@ function getInstallPackage(version) {
// Extract package name from tarball url or path.
function getPackageName(installPackage) {
if (installPackage.indexOf('.tgz') > -1) {
return installPackage.match(/^.+\/(.+)-.+\.tgz$/)[1];
// The package name could be with or without semver version, e.g. react-scripts-0.2.0-alpha.1.tgz
// However, this function returns package name only wihout semver version.
return installPackage.match(/^.+\/(.+?)(?:-\d+.+)?\.tgz$/)[1];
} else if (installPackage.indexOf('@') > 0) {
// Do not match @scope/ when stripping off @version or @tag
return installPackage.charAt(0) + installPackage.substr(1).split('@')[0];
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment