mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-04-01 12:42:50 +08:00
Fix eject for linked react-scripts (#1736)
* fix eject for linked react-scripts * path.resolve => resolveApp
This commit is contained in:
committed by
Dan Abramov
parent
1bfd5dafdf
commit
d7bcc1916a
3
packages/react-scripts/config/paths.js
vendored
3
packages/react-scripts/config/paths.js
vendored
@@ -114,7 +114,8 @@ module.exports = {
|
||||
ownNodeModules: resolveOwn('node_modules'), // This is empty on npm 3
|
||||
};
|
||||
|
||||
var reactScriptsPath = path.resolve('node_modules/react-scripts');
|
||||
var ownPackageJson = require('../package.json');
|
||||
var reactScriptsPath = resolveApp(`node_modules/${ownPackageJson.name}`);
|
||||
var reactScriptsLinked = fs.existsSync(reactScriptsPath) && fs.lstatSync(reactScriptsPath).isSymbolicLink();
|
||||
|
||||
// config before publish: we're in ./packages/react-scripts/config/
|
||||
|
||||
19
packages/react-scripts/scripts/eject.js
vendored
19
packages/react-scripts/scripts/eject.js
vendored
@@ -158,14 +158,17 @@ prompt(
|
||||
);
|
||||
console.log();
|
||||
|
||||
try {
|
||||
// remove react-scripts and react-scripts binaries from app node_modules
|
||||
Object.keys(ownPackage.bin).forEach(function(binKey) {
|
||||
fs.removeSync(path.join(appPath, 'node_modules', '.bin', binKey));
|
||||
});
|
||||
fs.removeSync(ownPath);
|
||||
} catch(e) {
|
||||
// It's not essential that this succeeds
|
||||
// "Don't destroy what isn't ours"
|
||||
if (ownPath.indexOf(appPath) === 0) {
|
||||
try {
|
||||
// remove react-scripts and react-scripts binaries from app node_modules
|
||||
Object.keys(ownPackage.bin).forEach(function(binKey) {
|
||||
fs.removeSync(path.join(appPath, 'node_modules', '.bin', binKey));
|
||||
});
|
||||
fs.removeSync(ownPath);
|
||||
} catch(e) {
|
||||
// It's not essential that this succeeds
|
||||
}
|
||||
}
|
||||
|
||||
if (fs.existsSync(paths.yarnLockFile)) {
|
||||
|
||||
Reference in New Issue
Block a user