-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlaunch.js
More file actions
23 lines (18 loc) · 840 Bytes
/
launch.js
File metadata and controls
23 lines (18 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
'use strict';
// launch.js — reliably clears ELECTRON_RUN_AS_NODE before starting Electron.
// VS Code's integrated terminal injects ELECTRON_RUN_AS_NODE=1, which makes
// the Electron binary behave like plain Node.js (no window, no app object).
// Deleting it here guarantees Electron always starts in GUI mode.
const { spawn } = require('child_process');
const path = require('path');
const env = Object.assign({}, process.env);
delete env.ELECTRON_RUN_AS_NODE;
// require('electron') returns the path to the electron binary in Node context
const electronBin = require('electron');
const extraArgs = process.argv.slice(2); // e.g. ['--inspect']
const child = spawn(electronBin, ['.'].concat(extraArgs), {
stdio: 'inherit',
env,
cwd: path.resolve(__dirname),
});
child.on('exit', function(code) { process.exit(code || 0); });