UNPKG

572 BJavaScriptView Raw
1/*!
2 * Copyright (c) 2012-2019 Digital Bazaar, Inc. All rights reserved.
3 */
4'use strict';
5
6// wait for initialization options from master
7process.on('message', init);
8
9// notify master to send initialization options
10process.send({type: 'bedrock.worker.started'});
11
12function init(msg) {
13 if(!(typeof msg === 'object' && msg.type === 'bedrock.worker.init')) {
14 return;
15 }
16 process.removeListener('message', init);
17
18 // ensure current working directory is correct
19 if(msg.cwd && process.cwd() !== msg.cwd) {
20 process.chdir(msg.cwd);
21 }
22
23 require(msg.script);
24}