File tree 2 files changed +13
-9
lines changed
2 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -114,7 +114,8 @@ module.exports = {
114
114
ownNodeModules : resolveOwn ( 'node_modules' ) , // This is empty on npm 3
115
115
} ;
116
116
117
- var reactScriptsPath = path . resolve ( 'node_modules/react-scripts' ) ;
117
+ var ownPackageJson = require ( '../package.json' ) ;
118
+ var reactScriptsPath = resolveApp ( `node_modules/${ ownPackageJson . name } ` ) ;
118
119
var reactScriptsLinked = fs . existsSync ( reactScriptsPath ) && fs . lstatSync ( reactScriptsPath ) . isSymbolicLink ( ) ;
119
120
120
121
// config before publish: we're in ./packages/react-scripts/config/
Original file line number Diff line number Diff line change @@ -158,14 +158,17 @@ prompt(
158
158
) ;
159
159
console . log ( ) ;
160
160
161
- try {
162
- // remove react-scripts and react-scripts binaries from app node_modules
163
- Object . keys ( ownPackage . bin ) . forEach ( function ( binKey ) {
164
- fs . removeSync ( path . join ( appPath , 'node_modules' , '.bin' , binKey ) ) ;
165
- } ) ;
166
- fs . removeSync ( ownPath ) ;
167
- } catch ( e ) {
168
- // It's not essential that this succeeds
161
+ // "Don't destroy what isn't ours"
162
+ if ( ownPath . indexOf ( appPath ) === 0 ) {
163
+ try {
164
+ // remove react-scripts and react-scripts binaries from app node_modules
165
+ Object . keys ( ownPackage . bin ) . forEach ( function ( binKey ) {
166
+ fs . removeSync ( path . join ( appPath , 'node_modules' , '.bin' , binKey ) ) ;
167
+ } ) ;
168
+ fs . removeSync ( ownPath ) ;
169
+ } catch ( e ) {
170
+ // It's not essential that this succeeds
171
+ }
169
172
}
170
173
171
174
if ( fs . existsSync ( paths . yarnLockFile ) ) {
You can’t perform that action at this time.
0 commit comments