Skip to content

Commit b5932d7

Browse files
committed
some code clean up
1 parent d1cab45 commit b5932d7

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

src/index.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,27 +104,35 @@ export const runDev = (
104104
let compileReqWatcher: chokidar.FSWatcher
105105
function start() {
106106
if (cfg.clear) process.stdout.write('\u001bc')
107+
107108
for (const watched of (opts.watch || '').split(',')) {
108109
if (watched) watcher.add(watched)
109110
}
111+
110112
let cmd = nodeArgs.concat(wrapper, script, scriptArgs)
111113
const childHookPath = compiler.getChildHookPath()
112114
cmd = (opts.priorNodeArgs || []).concat(['-r', childHookPath]).concat(cmd)
115+
113116
log.debug('Starting child process %s', cmd.join(' '))
117+
114118
child = fork(cmd[0], cmd.slice(1), {
115119
cwd: process.cwd(),
116120
env: process.env,
117121
})
122+
118123
starting = false
119-
//const compileReqWatcher = filewatcher({ forcePolling: opts.poll })
124+
120125
if (compileReqWatcher) {
121126
compileReqWatcher.close()
122127
}
128+
123129
compileReqWatcher = chokidar.watch([], {
124130
usePolling: opts.poll,
125131
interval: parseInt(opts.interval) || undefined,
126132
})
133+
127134
let currentCompilePath: string
135+
128136
fs.writeFileSync(compiler.getCompileReqFilePath(), '')
129137
compileReqWatcher.add(compiler.getCompileReqFilePath())
130138
compileReqWatcher.on('change', function (file) {
@@ -138,7 +146,7 @@ export const runDev = (
138146
const compiledPath = split[1]
139147
if (currentCompilePath == compiledPath) return
140148
currentCompilePath = compiledPath
141-
// console.log('compileReqWatcher file change', compile);
149+
142150
if (compiledPath) {
143151
compiler.compile({
144152
compile: compile,
@@ -147,9 +155,14 @@ export const runDev = (
147155
}
148156
})
149157
})
158+
150159
child.on('message', function (message: CompileParams) {
151-
if (!message.compiledPath || currentCompilePath === message.compiledPath)
160+
if (
161+
!message.compiledPath ||
162+
currentCompilePath === message.compiledPath
163+
) {
152164
return
165+
}
153166
currentCompilePath = message.compiledPath
154167
compiler.compile(message)
155168
})
@@ -247,21 +260,12 @@ export const runDev = (
247260
start()
248261
}
249262
}
250-
//compiler.restart = restart
251263

252264
// Relay SIGTERM
253265
process.on('SIGTERM', function () {
254266
log.debug('Process got SIGTERM')
255267
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 {
263268
process.exit(0)
264-
//}
265269
})
266270

267271
const compiler = makeCompiler(opts, {

0 commit comments

Comments
 (0)