async function run({
  version = 'latest',
  flavor = 'normal',
  platform = util.PLATFORM_KV[process.platform],
  arch = util.ARCH_KV[process.arch],
  srcDir = './src',
  cacheDir = './cache',
  glob = false,
  argv = [],
}) {
  /**
   * @type {child_process.ChildProcess | null}
   */
  let nwProcess = null;

  try {
    if (util.EXE_NAME[platform] === undefined) {
      throw new Error('Unsupported platform.');
    }
    if (glob === true) {
      throw new Error('Globbing is not supported with run mode.');
    }

    const nwDir = path.resolve(
      cacheDir,
      `nwjs${flavor === 'sdk' ? '-sdk' : ''}-v${version}-${platform}-${arch}`,
    );

    return new Promise((res, rej) => {
      /* It is assumed that the package.json is located at `${options.srcDir}/package.json` */
      nwProcess = child_process.spawn(
        path.resolve(nwDir, util.EXE_NAME[platform]),
        [...[srcDir], ...argv],
        { stdio: 'inherit' },
      );

      nwProcess.on('close', () => {
        res();
      });

      nwProcess.on('error', (error) => {
        console.error(error);
        rej(error);
      });
    });
  } catch (error) {
    console.error(error);
  }
  return nwProcess;
}
Run NW.js application.
@async
@function
@param  {RunOptions}    options  Run mode options
@returns {Promise<child_process.ChildProcess | null>} - A Node.js process object