File tree 2 files changed +14
-8
lines changed
packages/react-cy-scripts
2 files changed +14
-8
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-cy-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 @@ -157,13 +157,18 @@ prompt(
157
157
) ;
158
158
console . log ( ) ;
159
159
160
- try {
161
- // remove react-scripts and react-scripts binaries from app node_modules
162
- Object . keys ( ownPackage . bin ) . forEach ( function ( binKey ) {
163
- fs . removeSync ( path . join ( appPath , 'node_modules' , '.bin' , binKey ) ) ;
164
- } ) ;
165
- fs . removeSync ( ownPath ) ;
166
- } catch ( e ) { }
160
+ // "Don't destroy what isn't ours"
161
+ if ( ownPath . indexOf ( appPath ) === 0 ) {
162
+ try {
163
+ // remove react-scripts and react-scripts binaries from app node_modules
164
+ Object . keys ( ownPackage . bin ) . forEach ( function ( binKey ) {
165
+ fs . removeSync ( path . join ( appPath , 'node_modules' , '.bin' , binKey ) ) ;
166
+ } ) ;
167
+ fs . removeSync ( ownPath ) ;
168
+ } catch ( e ) {
169
+ // It's not essential that this succeeds
170
+ }
171
+ }
167
172
168
173
if ( fs . existsSync ( paths . yarnLockFile ) ) {
169
174
console . log ( cyan ( 'Running yarn...' ) ) ;
You can’t perform that action at this time.
0 commit comments