1
- const { watch } = require ( 'cpx' ) ;
1
+ const { watch, copy } = require ( 'cpx' ) ;
2
2
const { resolve } = require ( 'path' ) ;
3
3
const packageJson = require ( './../package.json' ) ;
4
4
@@ -22,15 +22,19 @@ if (!TARGET_DIR.includes('node_modules')) {
22
22
TARGET_DIR = `${ TARGET_DIR } /node_modules/${ packageJson . name } ` ;
23
23
}
24
24
25
-
26
25
rl . question ( `Watch for changes in '${ PROJECT_DIR } ' and copy to '${ TARGET_DIR } '? (y/n): ` , ( answer ) => {
27
26
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')) {
32
35
console . log ( `Copied ${ e . srcPath } to ${ e . dstPath } ` ) ;
33
- // }
36
+ // }
37
+ } ) ;
34
38
} ) ;
35
39
} else {
36
40
console . log ( 'Aborting watch.' ) ;
0 commit comments