How to use the execa.spawn function in execa

To help you get started, we’ve selected a few execa 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 callumlocke / esbox / src / lib / cli.js View on Github external
return debounce(() => {
    if (clear) process.stdout.write(clearScreen);

    console.log(brown(`${isMac ? '📦 ' : 'esbox'} ${path.relative(process.cwd(), userScript)}\n`));

    if (childProcess) childProcess.kill();

    childProcess = execa.spawn('node', [
      runner,
      '--file', userScript,
      '--clear', clear,
      '--babelrc', babelrc,
    ], { cwd, stdio: 'inherit' });

    childProcess.on('close', code => {
      if (code !== null && code !== 143) {
        console.log(brown(`\n${(code === 0 ? tick : cross)} exited with code ${code}`));

        if (!clear) console.log();
      }
    });

    return;
  }, 10, { maxWait: 1000 });