From 707e5b8275ec184a2ec205205a24c22344af6278 Mon Sep 17 00:00:00 2001 From: Jonathan Felchlin Date: Tue, 19 Dec 2017 13:23:31 -0800 Subject: [PATCH 1/2] Allowing for local "file:" prefixed scripts packages --- packages/create-react-app/createReactApp.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/create-react-app/createReactApp.js b/packages/create-react-app/createReactApp.js index e7dbbb35842..b42f49ca60c 100755 --- a/packages/create-react-app/createReactApp.js +++ b/packages/create-react-app/createReactApp.js @@ -268,7 +268,7 @@ function run( template, useYarn ) { - const packageToInstall = getInstallPackage(version); + const packageToInstall = getInstallPackage(version, originalDirectory); const allDependencies = ['react', 'react-dom', packageToInstall]; console.log('Installing packages. This might take a couple of minutes.'); @@ -365,11 +365,16 @@ function run( }); } -function getInstallPackage(version) { +function getInstallPackage(version, originalDirectory) { let packageToInstall = 'react-scripts'; const validSemver = semver.valid(version); if (validSemver) { packageToInstall += `@${validSemver}`; + } else if (version.match(/^file:/)) { + packageToInstall = `file:${path.resolve( + originalDirectory, + version.match(/^file:(.*)?$/)[1] + )}`; } else if (version) { // for tar.gz or alternative paths packageToInstall = version; @@ -459,6 +464,10 @@ function getPackageName(installPackage) { return Promise.resolve( installPackage.charAt(0) + installPackage.substr(1).split('@')[0] ); + } else if (installPackage.match(/^file:/)) { + const installPackagePath = installPackage.match(/^file:(.*)?$/)[1]; + const installPackageJson = require(path.join(installPackagePath, 'package.json')); + return Promise.resolve(installPackageJson.name); } return Promise.resolve(installPackage); } From 551ac17a789aad2e3d4bcd64b41712fba5067200 Mon Sep 17 00:00:00 2001 From: Jonathan Felchlin Date: Wed, 20 Dec 2017 10:48:19 -0800 Subject: [PATCH 2/2] Fixing test failure --- packages/create-react-app/createReactApp.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/create-react-app/createReactApp.js b/packages/create-react-app/createReactApp.js index b42f49ca60c..f8330a48d5f 100755 --- a/packages/create-react-app/createReactApp.js +++ b/packages/create-react-app/createReactApp.js @@ -370,7 +370,7 @@ function getInstallPackage(version, originalDirectory) { const validSemver = semver.valid(version); if (validSemver) { packageToInstall += `@${validSemver}`; - } else if (version.match(/^file:/)) { + } else if (version && version.match(/^file:/)) { packageToInstall = `file:${path.resolve( originalDirectory, version.match(/^file:(.*)?$/)[1]