feat: allow some NODE_OPTIONS in packaged apps (#20857)
* feat: allow some NODE_OPTIONS in packaged apps * fix: correctly detect packaged app
This commit is contained in:
parent
ecd9e1f26e
commit
38711233c5
3 changed files with 119 additions and 50 deletions
|
@ -53,6 +53,63 @@ describe('node feature', () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe('NODE_OPTIONS', () => {
|
||||
let child: childProcess.ChildProcessWithoutNullStreams
|
||||
let exitPromise: Promise<any[]>
|
||||
|
||||
afterEach(async () => {
|
||||
if (child && exitPromise) {
|
||||
const [code, signal] = await exitPromise
|
||||
expect(signal).to.equal(null)
|
||||
expect(code).to.equal(0)
|
||||
} else if (child) {
|
||||
child.kill()
|
||||
}
|
||||
})
|
||||
|
||||
it('fails for options disallowed by Node.js itself', (done) => {
|
||||
const env = Object.assign({}, process.env, { NODE_OPTIONS: '--v8-options' });
|
||||
child = childProcess.spawn(process.execPath, { env })
|
||||
|
||||
function cleanup () {
|
||||
child.stderr.removeListener('data', listener)
|
||||
child.stdout.removeListener('data', listener)
|
||||
}
|
||||
|
||||
let output = ''
|
||||
function listener (data: Buffer) {
|
||||
output += data
|
||||
if (/electron: --v8-options is not allowed in NODE_OPTIONS/m.test(output)) {
|
||||
cleanup()
|
||||
done()
|
||||
}
|
||||
}
|
||||
child.stderr.on('data', listener)
|
||||
child.stdout.on('data', listener)
|
||||
})
|
||||
|
||||
it('disallows crypto-related options', (done) => {
|
||||
const env = Object.assign({}, process.env, { NODE_OPTIONS: '--use-openssl-ca' });
|
||||
child = childProcess.spawn(process.execPath, ['--enable-logging'], { env })
|
||||
|
||||
function cleanup () {
|
||||
child.stderr.removeListener('data', listener)
|
||||
child.stdout.removeListener('data', listener)
|
||||
}
|
||||
|
||||
let output = ''
|
||||
function listener (data: Buffer) {
|
||||
output += data
|
||||
if (/The NODE_OPTION --use-openssl-ca is not supported in Electron/m.test(output)) {
|
||||
cleanup()
|
||||
done()
|
||||
}
|
||||
}
|
||||
child.stderr.on('data', listener)
|
||||
child.stdout.on('data', listener)
|
||||
})
|
||||
})
|
||||
|
||||
ifdescribe(features.isRunAsNodeEnabled())('inspector', () => {
|
||||
let child: childProcess.ChildProcessWithoutNullStreams
|
||||
let exitPromise: Promise<any[]>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue