@@ -45,6 +45,7 @@ const watchPackage = async (name, outputDir) => {
45
45
const destinationPath = getDestinationPath ( name , outputDir )
46
46
const sourceRootPath = path . join ( rootPath , `core/${ name } /` )
47
47
const dev = runCommand ( `yarn run dev` , { cwd : sourceRootPath } )
48
+
48
49
try {
49
50
await runCommand ( `yarn run build` , { cwd : sourceRootPath } )
50
51
} catch ( err ) {
@@ -65,8 +66,7 @@ const watchPackage = async (name, outputDir) => {
65
66
cpx . watch ( `${ sourcePath } /lib/**/*` , getDestinationPath ( name , 'lib' ) )
66
67
)
67
68
} else {
68
- const sync = cpx . watch ( `${ sourcePath } /**/*` , destinationPath )
69
- fileWatchers . push ( sync )
69
+ fileWatchers . push ( cpx . watch ( `${ sourcePath } /**/*` , destinationPath ) )
70
70
}
71
71
72
72
const unsubscribers = fileWatchers . map ( fileWatcher => {
@@ -81,12 +81,15 @@ const watchPackage = async (name, outputDir) => {
81
81
}
82
82
return stop
83
83
} )
84
+
84
85
const stop = ( ) => {
85
86
dev . cancel ( )
86
87
unsubscribers . forEach ( unsub => {
87
88
unsub ( )
88
89
} )
89
90
}
91
+
92
+ console . log ( 'watching package: ' , name )
90
93
return stop
91
94
}
92
95
@@ -97,20 +100,21 @@ const main = async () => {
97
100
for ( let stopWatching of watchStoppers ) {
98
101
stopWatching ( )
99
102
}
103
+
100
104
console . log ( `\nTerminated ${ watchStoppers . length } running processes\n` )
101
105
process . exit ( 0 )
102
106
} )
107
+
103
108
const build = runCommand ( `yarn packages:build` , { cwd : rootPath } )
109
+
104
110
watchStoppers . push ( ( ) => build . cancel ( ) )
111
+
105
112
await build
106
- for ( let package of packages ) {
107
- const stopWatchingPackage = await watchPackage (
108
- package . name ,
109
- package . outputDir
110
- )
111
- console . log ( 'watching package ' , package . name )
112
- watchStoppers . push ( stopWatchingPackage )
113
+
114
+ for ( const package of packages ) {
115
+ watchStoppers . push ( await watchPackage ( package . name , package . outputDir ) )
113
116
}
117
+
114
118
const dev = runCommand ( `yarn docz dev` , { cwd : __dirname } )
115
119
watchStoppers . push ( ( ) => dev . cancel ( ) )
116
120
}
0 commit comments