diff --git a/packages/react-scripts/config/paths.js b/packages/react-scripts/config/paths.js index 08b59ffccea..72a23cf80a9 100644 --- a/packages/react-scripts/config/paths.js +++ b/packages/react-scripts/config/paths.js @@ -86,7 +86,6 @@ module.exports = { yarnLockFile: resolveApp('yarn.lock'), testsSetup: resolveApp('client/setupTests.js'), appNodeModules: resolveApp('node_modules'), - ownNodeModules: resolveApp('node_modules'), nodePaths: nodePaths, publicUrl: getPublicUrl(resolveApp('package.json')), servedPath: getServedPath(resolveApp('package.json')) @@ -100,7 +99,6 @@ function resolveOwn(relativePath) { // config before eject: we're in ./node_modules/react-scripts/config/ module.exports = { appPath: resolveApp('.'), - ownPath: resolveApp('node_modules/react-scripts'), appBuild: resolveApp(buildPath), appPublic: resolveApp('client/public'), appHtml: resolveApp('client/public/index.html'), @@ -110,11 +108,12 @@ module.exports = { yarnLockFile: resolveApp('yarn.lock'), testsSetup: resolveApp('client/setupTests.js'), appNodeModules: resolveApp('node_modules'), - // this is empty with npm3 but node resolution searches higher anyway: - ownNodeModules: resolveOwn('node_modules'), nodePaths: nodePaths, publicUrl: getPublicUrl(resolveApp('package.json')), - servedPath: getServedPath(resolveApp('package.json')) + servedPath: getServedPath(resolveApp('package.json')), + // These properties only exist before ejecting: + ownPath: resolveOwn('.'), + ownNodeModules: resolveOwn('node_modules'), // This is empty on npm 3 }; var reactScriptsPath = path.resolve('node_modules/react-scripts'); @@ -124,7 +123,6 @@ var reactScriptsLinked = fs.existsSync(reactScriptsPath) && fs.lstatSync(reactSc if (!reactScriptsLinked && __dirname.indexOf(path.join('packages', 'react-scripts', 'config')) !== -1) { module.exports = { appPath: resolveApp('.'), - ownPath: resolveOwn('.'), appBuild: resolveOwn('../../' + buildPath), appPublic: resolveOwn('template/client/public'), appHtml: resolveOwn('template/client/public/index.html'), @@ -134,10 +132,12 @@ if (!reactScriptsLinked && __dirname.indexOf(path.join('packages', 'react-script yarnLockFile: resolveOwn('template/yarn.lock'), testsSetup: resolveOwn('template/client/setupTests.js'), appNodeModules: resolveOwn('node_modules'), - ownNodeModules: resolveOwn('node_modules'), nodePaths: nodePaths, publicUrl: getPublicUrl(resolveOwn('package.json')), - servedPath: getServedPath(resolveOwn('package.json')) + servedPath: getServedPath(resolveOwn('package.json')), + // These properties only exist before ejecting: + ownPath: resolveOwn('.'), + ownNodeModules: resolveOwn('node_modules'), }; } // @remove-on-eject-end diff --git a/packages/react-scripts/scripts/eject.js b/packages/react-scripts/scripts/eject.js index 701907fa436..e2bde5ddd11 100644 --- a/packages/react-scripts/scripts/eject.js +++ b/packages/react-scripts/scripts/eject.js @@ -114,14 +114,17 @@ prompt( console.log(cyan('Updating the scripts')); delete appPackage.scripts['eject']; Object.keys(appPackage.scripts).forEach(function (key) { - appPackage.scripts[key] = appPackage.scripts[key] - .replace(/react-scripts (\w+)/g, 'node scripts/$1.js'); - console.log( - ' Replacing ' + - cyan('"react-scripts ' + key + '"') + - ' with ' + - cyan('"node scripts/' + key + '.js"') - ); + Object.keys(ownPackage.bin).forEach(function (binKey) { + var regex = new RegExp(binKey + ' (\\w+)', 'g'); + appPackage.scripts[key] = appPackage.scripts[key] + .replace(regex, 'node scripts/$1.js'); + console.log( + ' Replacing ' + + cyan('"' + binKey + ' ' + key + '"') + + ' with ' + + cyan('"node scripts/' + key + '.js"') + ); + }); }); console.log();