How to use the @electron-forge/core.api.start function in @electron-forge/core

To help you get started, we’ve selected a few @electron-forge/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github electron-userland / electron-forge / packages / api / cli / src / electron-forge-start.ts View on Github external
enableLogging: !!program.enableLogging,
    runAsNode: !!program.runAsNode,
    inspect: !!program.inspectElectron,
  };

  if (program.vscode && appArgs) {
    // Args are in the format ~arg~ so we need to strip the "~"
    appArgs = appArgs
      .map((arg) => arg.substr(1, arg.length - 2))
      .filter((arg) => arg.length > 0);
  }

  if (program.appPath) opts.appPath = program.appPath;
  if (appArgs) opts.args = appArgs;

  const spawned = await api.start(opts);

  await new Promise((resolve) => {
    const listenForExit = (child: ElectronProcess) => {
      let onExit: NodeJS.ExitListener;
      let onRestart: (newChild: ElectronProcess) => void;
      const removeListeners = () => {
        child.removeListener('exit', onExit);
        child.removeListener('restarted', onRestart);
      };
      onExit = (code: number) => {
        removeListeners();
        if (spawned.restarted) return;
        if (code !== 0) {
          process.exit(code);
        }
        resolve();