openWindow = (url: string) => {
  const urlKey = url.replace(/(\/|:|\.)/g, '');

  if (openedWindows[urlKey]) {
    try {
      return openedWindows[urlKey].show();
    } catch (err) {
      if (!err.message.includes('Object has been destroyed')) {
        console.error(err);
        throw new Error('Unhandled error');
      }
      // else swallow Object has been destroyed - Window could be closed
    }
  }

  const win = new BrowserWindow({
    width: 800,
    height: 600,
    webPreferences: {
      devTools: false,
    },
  });
  // Remove the menu
  win.setMenu(null);
  win.loadURL(url);
  win.show();

  // Save Window so we can open it later
  openedWindows[urlKey] = win;
}
Thin wrapper around electron `shell`, and other shell-like functions