fix: NODE_OPTIONS parsing for child processes on macOS (#46209)
* fix: NODE_OPTIONS parsing for child processes on macOS * chore: temporarily disable test * chore: apply review feedback * chore: fix build
This commit is contained in:
parent
abaef13c0b
commit
a86e44b176
6 changed files with 62 additions and 0 deletions
1
spec/fixtures/apps/node-options-utility-process/fail.js
vendored
Normal file
1
spec/fixtures/apps/node-options-utility-process/fail.js
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
process.exit(1);
|
15
spec/fixtures/apps/node-options-utility-process/main.js
vendored
Normal file
15
spec/fixtures/apps/node-options-utility-process/main.js
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
const { app, utilityProcess } = require('electron');
|
||||
|
||||
const path = require('node:path');
|
||||
|
||||
app.whenReady().then(() => {
|
||||
const child = utilityProcess.fork(path.join(__dirname, 'noop.js'), [], {
|
||||
stdio: 'inherit',
|
||||
env: {
|
||||
...process.env,
|
||||
NODE_OPTIONS: `--require ${path.join(__dirname, 'fail.js')}`
|
||||
}
|
||||
});
|
||||
|
||||
child.once('exit', (code) => app.exit(code));
|
||||
});
|
1
spec/fixtures/apps/node-options-utility-process/noop.js
vendored
Normal file
1
spec/fixtures/apps/node-options-utility-process/noop.js
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
process.exit(0);
|
4
spec/fixtures/apps/node-options-utility-process/package.json
vendored
Normal file
4
spec/fixtures/apps/node-options-utility-process/package.json
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"name": "electron-test-node-options-utility-process",
|
||||
"main": "main.js"
|
||||
}
|
|
@ -697,6 +697,29 @@ describe('node feature', () => {
|
|||
expect(code).to.equal(1);
|
||||
});
|
||||
|
||||
it('does allow --require in utility process of non-packaged apps', async () => {
|
||||
const appPath = path.join(fixtures, 'apps', 'node-options-utility-process');
|
||||
// App should exit with code 1.
|
||||
const child = childProcess.spawn(process.execPath, [appPath]);
|
||||
const [code] = await once(child, 'exit');
|
||||
expect(code).to.equal(1);
|
||||
});
|
||||
|
||||
// TODO(deepak1556): will be enabled in follow-up PR
|
||||
// https://github.com/electron/electron/pull/46210
|
||||
it.skip('does not allow --require in utility process of packaged apps', async () => {
|
||||
const appPath = path.join(fixtures, 'apps', 'node-options-utility-process');
|
||||
// App should exit with code 1.
|
||||
const child = childProcess.spawn(process.execPath, [appPath], {
|
||||
env: {
|
||||
...process.env,
|
||||
ELECTRON_FORCE_IS_PACKAGED: 'true'
|
||||
}
|
||||
});
|
||||
const [code] = await once(child, 'exit');
|
||||
expect(code).to.equal(0);
|
||||
});
|
||||
|
||||
it('does not allow --require in packaged apps', async () => {
|
||||
const appPath = path.join(fixtures, 'module', 'noop.js');
|
||||
const env = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue