如何从“ execa”的子进程中获取console.log()输出?

时间:2019-06-11 08:39:54

标签: node.js child-process

下面的代码将启动Electron应用程序,但是,主过程中的console.log()将不可用。

import executeExternalCommand, { ExecaReturnValue } from 'execa';

async startInitializeProjectGUI(): Promise<void> {

  const executionResult: ExecaReturnValue<string> = await executeExternalCommand(
      'electron',
      ['InitializeProject_GUI.js'], // console.log() is here
      { cwd: __dirname }
  );

  if (executionResult.failed) {
    Promise.reject(new Error('Can not start "electron"'));
  }

  return;
}

如何使用execa获取子进程的控制台输出?

0 个答案:

没有答案