1 | require('v8-compile-cache');
|
2 | const Pipeline = require('./Pipeline');
|
3 |
|
4 | let pipeline;
|
5 |
|
6 | exports.init = function(options, callback) {
|
7 | pipeline = new Pipeline(options || {});
|
8 | Object.assign(process.env, options.env || {});
|
9 | process.env.HMR_PORT = options.hmrPort;
|
10 | process.env.HMR_HOSTNAME = options.hmrHostname;
|
11 | callback();
|
12 | };
|
13 |
|
14 | exports.run = async function(path, pkg, options, isWarmUp, callback) {
|
15 | try {
|
16 | options.isWarmUp = isWarmUp;
|
17 | var result = await pipeline.process(path, pkg, options);
|
18 |
|
19 | callback(null, result);
|
20 | } catch (err) {
|
21 | let returned = err;
|
22 | returned.fileName = path;
|
23 | callback(returned);
|
24 | }
|
25 | };
|
26 |
|
27 | process.on('unhandledRejection', function(err) {
|
28 |
|
29 | if (err.code !== 'ERR_IPC_CHANNEL_CLOSED') {
|
30 | console.error('Unhandled promise rejection:', err.stack);
|
31 | }
|
32 | });
|