1- const  {  watch }  =  require ( 'cpx' ) ; 
1+ const  {  watch,  copy  }  =  require ( 'cpx' ) ; 
22const  {  resolve }  =  require ( 'path' ) ; 
33const  packageJson  =  require ( './../package.json' ) ; 
44
@@ -22,15 +22,19 @@ if (!TARGET_DIR.includes('node_modules')) {
2222  TARGET_DIR  =  `${ TARGET_DIR } ${ packageJson . name }  ; 
2323} 
2424
25- 
2625rl . question ( `Watch for changes in '${ PROJECT_DIR } ${ TARGET_DIR }  ,  ( answer )  =>  { 
2726  if  ( answer . toLowerCase ( )  ===  'y' )  { 
28-     console . log ( 'For the watch! (watching has begun)' ) ; 
29-     const  watcher  =  watch ( PROJECT_DIR  +  '/{ios,android,lib}/**/*.*' ,  TARGET_DIR ,  {  verbose : true } ) ; 
30-     watcher . on ( 'copy' ,  ( e )  =>  { 
31-      // if (!e.srcPath.startsWith('node_modules')) { 
27+     // flat copy node_modules as we're not watching it 
28+     console . log ( 'Copying node_modules directory...' ) ; 
29+     copy ( PROJECT_DIR  +  '/node_modules/**/*.*' ,  TARGET_DIR . replace ( `/${ packageJson . name }  ) ,  {  clean : true  } ,  ( )  =>  { 
30+       console . log ( 'Copy complete.' ) ; 
31+       console . log ( 'Watching for changes in project directory... (excludes node_modules)' ) ; 
32+       const  watcher  =  watch ( PROJECT_DIR  +  '/{ios,android,lib}/**/*.*' ,  TARGET_DIR ,  {  verbose : true  } ) ; 
33+       watcher . on ( 'copy' ,  ( e )  =>  { 
34+         // if (!e.srcPath.startsWith('node_modules')) { 
3235        console . log ( `Copied ${ e . srcPath } ${ e . dstPath }  ) ; 
33-       // } 
36+         // } 
37+       } ) ; 
3438    } ) ; 
3539  }  else  { 
3640    console . log ( 'Aborting watch.' ) ; 
0 commit comments