-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bin.js
executable file
·53 lines (42 loc) · 1.68 KB
/
bin.js
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
#!/usr/bin/env node
const spawn = require('child_process').spawn;
const pathToApp = process.env.NODE_ENV === 'development' ? 'app.js' : require.resolve('sustainus/app.js');
const pathToSustainus = process.env.NODE_ENV === 'development' ? './' : pathToApp.replace('/app.js', '');
const fkill = require('fkill');
createElectronProcess();
function createElectronProcess() {
const childProcess = spawn('node_modules/.bin/electron', [pathToApp], {
// stdio: 'ignore',
// detached: true,
cwd: pathToSustainus
});
// TODO we might want to be more sophisticated with reading data from the child...perhaps using readline or some other delimiter
// TODO we want to make it cross-platform though
childProcess.stdout.on('data', async (data) => {
// if (data.includes('SUSTAINUS_RESTART')) {
// // we need to make sure to kill Zwitterion
// await fkill(':10000', {
// silent: true
// });
// await fkill(':10001', {
// silent: true
// });
// createElectronProcess();
// process.exit(0);
// }
// TODO we should clean all of this up...for some reason this is working without the SUSTAINUS_RESTART, but I do not know why
if (data.includes('SUSTAINUS_DO_NOTHING')) {
// we need to make sure to kill Zwitterion
await fkill(':10000', {
silent: true
});
await fkill(':10001', {
silent: true
});
process.exit(0);
}
});
// childProcess.stderr.on('data', (data) => {
// console.log(data.toString());
// });
}