-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev-wrapper.js
More file actions
56 lines (50 loc) · 1.59 KB
/
dev-wrapper.js
File metadata and controls
56 lines (50 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const { spawn } = require('child_process');
const path = require('path');
// Start Discord interaction service
const discordProcess = spawn('node', ['./discordInteraction/index.js'], {
stdio: 'inherit',
cwd: __dirname
});
// Create a modified environment for electron-nuxt
const electronNuxtEnv = {...process.env};
electronNuxtEnv.NODE_OPTIONS = '--openssl-legacy-provider';
// We need to patch the Electron launcher to not inherit NODE_OPTIONS
const electronNuxtProcess = spawn('node', ['-e', `
const originalSpawn = require('child_process').spawn;
require('child_process').spawn = function(command, args, options) {
if (command.includes('electron')) {
// Clear NODE_OPTIONS for Electron
if (options && options.env) {
delete options.env.NODE_OPTIONS;
} else if (options) {
options.env = {...process.env};
delete options.env.NODE_OPTIONS;
} else {
options = { env: {...process.env} };
delete options.env.NODE_OPTIONS;
}
}
return originalSpawn.call(this, command, args, options);
};
require('./.electron-nuxt/dev.js');
`], {
stdio: 'inherit',
cwd: __dirname,
env: electronNuxtEnv
});
// Handle process termination
process.on('SIGINT', () => {
discordProcess.kill();
electronNuxtProcess.kill();
process.exit();
});
discordProcess.on('exit', (code) => {
console.log(`Discord service exited with code ${code}`);
electronNuxtProcess.kill();
process.exit(code);
});
electronNuxtProcess.on('exit', (code) => {
console.log(`Electron-nuxt exited with code ${code}`);
discordProcess.kill();
process.exit(code);
});