blob: f55c1a67c49ec22e6fd82ae055a6e3a87cae9caa (
plain)
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
|
/* eslint-disable node-core/require-common-first, node-core/required-modules */
'use strict';
if (module.parent) {
const { spawnSync } = require('child_process');
function runModuleAs(filename, flags, spawnOptions, role) {
return spawnSync(process.execPath,
[...flags, __filename, role, filename], spawnOptions);
}
module.exports = runModuleAs;
return;
}
const { Worker, isMainThread, workerData } = require('worker_threads');
if (isMainThread) {
if (process.argv[2] === 'worker') {
new Worker(__filename, {
workerData: process.argv[3]
});
return;
}
require(process.argv[3]);
} else {
require(workerData);
}
|