electron/spec/fixtures/api/utility-process/env-app/main.js
Milan Burda d78f37ec8f
refactor: use node scheme imports in spec (#38487)
Co-authored-by: Milan Burda <miburda@microsoft.com>
2023-06-15 10:42:27 -04:00

22 lines
544 B
JavaScript

const { app, utilityProcess } = require('electron');
const path = require('node:path');
app.whenReady().then(() => {
let child = null;
if (app.commandLine.hasSwitch('create-custom-env')) {
child = utilityProcess.fork(path.join(__dirname, 'test.js'), {
env: {
FROM: 'child'
}
});
} else {
child = utilityProcess.fork(path.join(__dirname, 'test.js'));
}
child.on('message', (data) => {
process.stdout.write(data);
process.stdout.end();
});
child.on('exit', () => {
app.quit();
});
});