Fix eject for linked react-scripts (#1736)

* fix eject for linked react-scripts

* path.resolve => resolveApp
This commit is contained in:
Valerii Sorokobatko
2017-03-06 19:44:18 +02:00
committed by Dan Abramov
parent 1bfd5dafdf
commit d7bcc1916a
2 changed files with 13 additions and 9 deletions

View File

@@ -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)) {