From c7c2e63f8ec9ac3ab78b2cfb3b8d597adfc4f3a0 Mon Sep 17 00:00:00 2001 From: creynders Date: Fri, 27 Jan 2017 12:44:47 +0100 Subject: [PATCH] eject: Additionally remove `react-scripts` from dependencies ATM if react-scripts is (erroneously) declared in `dependencies` instead of `devDependencies` or isn't declared at all, the `eject` script will fail half-way. This change makes it more robust, react-scripts will be removed from either, if present. --- packages/react-scripts/scripts/eject.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/react-scripts/scripts/eject.js b/packages/react-scripts/scripts/eject.js index 86dbc15c3ae..3844f2b8525 100644 --- a/packages/react-scripts/scripts/eject.js +++ b/packages/react-scripts/scripts/eject.js @@ -93,8 +93,14 @@ prompt( console.log(cyan('Updating the dependencies')); var ownPackageName = ownPackage.name; - console.log(' Removing ' + cyan(ownPackageName) + ' from devDependencies'); - delete appPackage.devDependencies[ownPackageName]; + if(appPackage.devDependencies[ownPackageName]){ + console.log(' Removing ' + cyan(ownPackageName) + ' from devDependencies'); + delete appPackage.devDependencies[ownPackageName]; + } + if(appPackage.dependencies[ownPackageName]){ + console.log(' Removing ' + cyan(ownPackageName) + ' from dependencies'); + delete appPackage.dependencies[ownPackageName]; + } Object.keys(ownPackage.dependencies).forEach(function (key) { // For some reason optionalDependencies end up in dependencies after install