Skip to content

Commit

Permalink
Fix using pre-release tags with a tarball url in --scripts-version (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
jihchi authored and gaearon committed Oct 12, 2016
1 parent 88c15d0 commit c5f5b00
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/create-react-app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit c5f5b00

Please sign in to comment.