@@ -104,27 +104,35 @@ export const runDev = (
104
104
let compileReqWatcher : chokidar . FSWatcher
105
105
function start ( ) {
106
106
if ( cfg . clear ) process . stdout . write ( '\u001bc' )
107
+
107
108
for ( const watched of ( opts . watch || '' ) . split ( ',' ) ) {
108
109
if ( watched ) watcher . add ( watched )
109
110
}
111
+
110
112
let cmd = nodeArgs . concat ( wrapper , script , scriptArgs )
111
113
const childHookPath = compiler . getChildHookPath ( )
112
114
cmd = ( opts . priorNodeArgs || [ ] ) . concat ( [ '-r' , childHookPath ] ) . concat ( cmd )
115
+
113
116
log . debug ( 'Starting child process %s' , cmd . join ( ' ' ) )
117
+
114
118
child = fork ( cmd [ 0 ] , cmd . slice ( 1 ) , {
115
119
cwd : process . cwd ( ) ,
116
120
env : process . env ,
117
121
} )
122
+
118
123
starting = false
119
- //const compileReqWatcher = filewatcher({ forcePolling: opts.poll })
124
+
120
125
if ( compileReqWatcher ) {
121
126
compileReqWatcher . close ( )
122
127
}
128
+
123
129
compileReqWatcher = chokidar . watch ( [ ] , {
124
130
usePolling : opts . poll ,
125
131
interval : parseInt ( opts . interval ) || undefined ,
126
132
} )
133
+
127
134
let currentCompilePath : string
135
+
128
136
fs . writeFileSync ( compiler . getCompileReqFilePath ( ) , '' )
129
137
compileReqWatcher . add ( compiler . getCompileReqFilePath ( ) )
130
138
compileReqWatcher . on ( 'change' , function ( file ) {
@@ -138,7 +146,7 @@ export const runDev = (
138
146
const compiledPath = split [ 1 ]
139
147
if ( currentCompilePath == compiledPath ) return
140
148
currentCompilePath = compiledPath
141
- // console.log('compileReqWatcher file change', compile);
149
+
142
150
if ( compiledPath ) {
143
151
compiler . compile ( {
144
152
compile : compile ,
@@ -147,9 +155,14 @@ export const runDev = (
147
155
}
148
156
} )
149
157
} )
158
+
150
159
child . on ( 'message' , function ( message : CompileParams ) {
151
- if ( ! message . compiledPath || currentCompilePath === message . compiledPath )
160
+ if (
161
+ ! message . compiledPath ||
162
+ currentCompilePath === message . compiledPath
163
+ ) {
152
164
return
165
+ }
153
166
currentCompilePath = message . compiledPath
154
167
compiler . compile ( message )
155
168
} )
@@ -247,21 +260,12 @@ export const runDev = (
247
260
start ( )
248
261
}
249
262
}
250
- //compiler.restart = restart
251
263
252
264
// Relay SIGTERM
253
265
process . on ( 'SIGTERM' , function ( ) {
254
266
log . debug ( 'Process got SIGTERM' )
255
267
killChild ( )
256
- // if (opts['restart-terminated']) {
257
- // const timeout = opts['restart-terminated'] || 0
258
- // log.info('Restarting terminated in ' + timeout + ' seconds')
259
- // setTimeout(() => {
260
- // start()
261
- // }, timeout)
262
- // } else {
263
268
process . exit ( 0 )
264
- //}
265
269
} )
266
270
267
271
const compiler = makeCompiler ( opts , {
0 commit comments