Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function connectToLocalServer(serverMode, serverArgs, win) {
const server =
serverMode === "edit"
? startInEditMode(".", serverArgs)
: startInCloneMode(".", serverArgs);
const {
adminPort: localServerPort,
adminToken: token,
close: closeLocalServer
} = await server;
win.webContents.on("will-prevent-unload", async event => {
console.log(JSON.stringify({ event: "closingWithUnsavedChanges" }));
const choice = process.env.SKIP_UNSAVED_DIALOG
? 1
: await electron.dialog.showMessageBox(win, beforeCloseDialogParams);
const leave = choice === 0;
if (leave) {
event.preventDefault();
}