0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-28 06:28:40 +01:00
nodejs/tools/run-worker.js
Rafael Gonzaga 00c222593e
src,process: add permission model
Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com>
PR-URL: https://github.com/nodejs/node/pull/44004
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2023-02-23 18:11:51 +00:00

20 lines
679 B
JavaScript

'use strict';
if (typeof require === 'undefined') {
console.log('1..0 # Skipped: Not being run as CommonJS');
process.exit(0);
}
const path = require('path');
const { Worker } = require('worker_threads');
// When --experimental-permission is enabled, the process
// aren't able to spawn any worker unless --allow-worker is passed.
// Therefore, we skip the permission tests for custom-suites-freestyle
if (process.permission && !process.permission.has('worker')) {
console.log('1..0 # Skipped: Not being run with worker_threads permission');
process.exit(0);
}
new Worker(path.resolve(process.cwd(), process.argv[2]))
.on('exit', (code) => process.exitCode = code);