-
Notifications
You must be signed in to change notification settings - Fork 317
/
Copy pathprod.js
34 lines (30 loc) · 1.03 KB
/
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
34
/* eslint-disable */
const workerFarm = require('worker-farm');
const locales = require('@box/languages');
const numCPUs = require('os').cpus().length;
const execSync = require('child_process').execSync;
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: 3,
maxRetries: 0
},
require.resolve('./build_locale.js')
);
[true, false].forEach((react) => {
locales.forEach((locale) => {
workers(locale, react, (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`);
}
});
});
});