Files
node/test/parallel/test-process-execve-worker-threads.js
T
Paolo Insogna 2ce79787de process: add execve
PR-URL: https://github.com/nodejs/node/pull/56496
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Bryan English <bryan@bryanenglish.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2025-04-17 10:51:51 -03:00

22 lines
570 B
JavaScript

'use strict';
const { isWindows, mustCall, skip } = require('../common');
const { throws } = require('assert');
const { isMainThread, Worker } = require('worker_threads');
if (isWindows) {
skip('process.execve is not available in Windows');
}
if (isMainThread) {
new Worker(__filename);
} else {
throws(mustCall(() => {
process.execve(
process.execPath,
[__filename, 'replaced'],
{ ...process.env, EXECVE_A: 'FIRST', EXECVE_B: 'SECOND', CWD: process.cwd() }
);
}), { name: 'TypeError', code: 'ERR_WORKER_UNSUPPORTED_OPERATION' });
}