事件:'spawn'
【Event: 'spawn'】
当子进程成功生成时,会触发 'spawn' 事件。如果子进程未能成功生成,则不会触发 'spawn' 事件,而是会触发 'error' 事件。
【The 'spawn' event is emitted once the child process has spawned successfully.
If the child process does not spawn successfully, the 'spawn' event is not
emitted and the 'error' event is emitted instead.】
如果被触发,'spawn' 事件会在所有其他事件之前以及接收到任何通过 stdout 或 stderr 的数据之前触发。
【If emitted, the 'spawn' event comes before all other events and before any
data is received via stdout or stderr.】
'spawn' 事件会触发,无论在被生成的进程中是否发生错误。例如,如果 bash some-command 成功生成,'spawn' 事件将会触发,尽管 bash 可能无法生成 some-command。这个注意事项在使用 { shell: true } 时也同样适用。
【The 'spawn' event will fire regardless of whether an error occurs within
the spawned process. For example, if bash some-command spawns successfully,
the 'spawn' event will fire, though bash may fail to spawn some-command.
This caveat also applies when using { shell: true }.】