23 lines
539 B
JavaScript
23 lines
539 B
JavaScript
|
const { app, utilityProcess } = require('electron');
|
||
|
const path = require('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();
|
||
|
});
|
||
|
});
|