Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async _attemptToConnect (port, host) {
this.socket.connect(port, host);
var connectionPromise = Promise.race([
promisifyEvent(this.socket, 'connect'),
promisifyEvent(this.socket, 'error')
]);
return await connectionPromise
.then(() => true)
.catch(() => {
this.socket.removeAllListeners('connect');
return delay(connectionRetryDelay);
});
}
async function runWMIC (args) {
const wmicProcess = spawn('wmic.exe', args, { detached: true });
let wmicOutput = '';
wmicProcess.stdout.on('data', data => {
wmicOutput += data.toString();
});
try {
await Promise.race([
promisifyEvent(wmicProcess.stdout, 'end'),
promisifyEvent(wmicProcess, 'error')
]);
return wmicOutput;
}
catch (e) {
return '';
}
}
mainPath = path.join(process.cwd(), mainPath);
var config = getConfig(id, mainPath);
var ipcServer = new IPCServer(config);
await ipcServer.start();
var ports = await getFreePorts(2);
startElectron(config, ports);
var hookCode = getHookCode(config, pageUrl);
var debugClient = new NodeDebug(ports[0]);
var inspectClient = new NodeInspect(ports[1]);
await Promise.race([
injectHookCode(debugClient, hookCode),
injectHookCode(inspectClient, hookCode)
]);
await ipcServer.connect();
var injectingStatus = await ipcServer.getInjectingStatus();
if (!injectingStatus.completed) {
await ipcServer.terminateProcess();
ipcServer.stop();
throw new Error(ERRORS.render(ERRORS.mainUrlWasNotLoaded, {
mainWindowUrl: config.mainWindowUrl,
openedUrls: injectingStatus.openedUrls