UNPKG

1.3 kBJavaScriptView Raw
1var ipc = require('node-ipc'),
2 serverName = 'webpack',
3 watchDoneHandler = require('./watchDoneHandler');
4
5module.exports = {
6
7 /**
8 * Start IPC server and listens for 'done' message from child processes
9 * @param {any} callback - callback invoked once 'done' has been emitted by each confugration
10 * @param {any} configIndices - array indices of configuration
11 */
12 startWatchIPCServer: function startWatchIPCServer(callback, configIndices) {
13 ipc.config.id = serverName;
14 ipc.config.retry = 3;
15 ipc.config.silent = true;
16
17 ipc.serve(
18 function() {
19 ipc.server.on(
20 'done',
21 watchDoneHandler.bind(this, callback, ipc, configIndices)
22 );
23 }
24 );
25 ipc.server.start();
26 },
27
28 /*
29 * Notifies parent process that a complete compile has occured in watch mode
30 * @param {any} index
31 */
32 notifyIPCWatchCompileDone: function notifyIPCWatchCompileDone(index) {
33 ipc.config.id = serverName + index;
34 ipc.config.stopRetrying = 3;
35 ipc.config.silent = true;
36
37 ipc.connectTo(
38 serverName,
39 function() {
40 ipc.of.webpack.emit('done', index);
41 }
42 );
43 }
44}