2023-12-06 02:23:54 +00:00
|
|
|
const { execFileSync } = require('node:child_process');
|
|
|
|
const path = require('node:path');
|
|
|
|
|
|
|
|
const fixtures = path.resolve(__dirname, '..');
|
2024-01-04 07:34:08 +00:00
|
|
|
const failJs = path.join(fixtures, 'module', 'fail.js');
|
2023-12-06 02:23:54 +00:00
|
|
|
|
|
|
|
const env = {
|
|
|
|
ELECTRON_RUN_AS_NODE: 'true',
|
|
|
|
// Process will exit with 1 if NODE_OPTIONS is accepted.
|
2024-01-04 07:34:08 +00:00
|
|
|
NODE_OPTIONS: `--require "${failJs}"`,
|
|
|
|
// Try bypassing the check with NODE_REPL_EXTERNAL_MODULE.
|
|
|
|
NODE_REPL_EXTERNAL_MODULE: failJs
|
2023-12-06 02:23:54 +00:00
|
|
|
};
|
|
|
|
// Provide a lower cased NODE_OPTIONS in case some code ignores case sensitivity
|
|
|
|
// when reading NODE_OPTIONS.
|
|
|
|
env.node_options = env.NODE_OPTIONS;
|
|
|
|
try {
|
|
|
|
execFileSync(process.argv[2],
|
|
|
|
['--require', path.join(fixtures, 'module', 'noop.js')],
|
|
|
|
{ env, stdio: 'inherit' });
|
|
|
|
process.exit(0);
|
|
|
|
} catch (error) {
|
|
|
|
console.log('NODE_OPTIONS passed to child');
|
|
|
|
process.exit(1);
|
|
|
|
}
|