Coffeescript函数返回对象而不是字符串

时间:2019-03-07 18:50:47

标签: javascript coffeescript

我有一个coffeescript函数(取自https://gist.github.com/dzimine/9612702),应该返回一个字符串,但我却得到了“ object Object”。该功能基本上允许您运行任何命令。我检查了typeof stdout,它说这是一个字符串。有谁知道为什么它要返回一个对象?

cmd = (command) ->
  @exec = require('child_process').exec

  @exec command, (error, stdout, stderr) -> 
    if error
      console.log "#{error}"
      console.log "#{stderr}"
    else
      return stdout

0 个答案:

没有答案