@node-red/util.exec

运行集成事件日志的系统命令

运行(command, args, options, emit) → {Promise}

运行系统命令,并将标准输出/错误作为“事件日志”事件在 @node-red/util/events 处理程序上发出。

此函数的主要参数与传递给 child_process.spawn 的参数相同

参数
名称 类型 描述
命令 字符串

要运行的命令

参数 数组

命令的参数

选项 对象

传递给 child_process.spawn 的选项

发出 布尔值

是否为标准输出/错误的每一行向事件日志发出事件

返回
类型
承诺

一个当命令完成时解析(rc=0)或拒绝(rc!=0)的 Promise。Promise 的值是一个如下形式的对象:

  {
      code: <exit code>,
      stdout: <standard output from the command>,
      stderr: <standard error from the command>
  }