forked from box/box-annotations
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprod.js
33 lines (29 loc) · 983 Bytes
/
prod.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const workerFarm = require('worker-farm');
const locales = require('@box/languages');
const numCPUs = require('os').cpus().length;
const { execSync } = require('child_process');
const path = require('path');
const filename = path.basename(__filename);
const bundleCount = locales.length * 2; // One with react, and one without
let counter = 0;
const workers = workerFarm(
{
maxConcurrentWorkers: numCPUs - 2,
maxRetries: 0,
},
require.resolve('./build_locale.js'),
);
/* eslint-disable */
locales.forEach(locale => {
workers(locale, error => {
if (++counter === bundleCount || error) {
// terminate after all locales have been processed
workerFarm.end(workers);
}
if (error) {
// kill the node process that spawns the workers as well as all processes been spawned
execSync(`ps ax | grep "${filename}" | cut -b1-06 | xargs -t kill`);
}
});
});
/* eslint-enable */