我有一个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