在 node.js 中,我想找到一种获取 Unix 终端命令输出的方法。有没有办法做到这一点?
function getCommandOutput(commandString){
// now how can I implement this function?
// getCommandOutput("ls") should print the terminal output of the shell command "ls"
}
原文由 Anderson Green 发布,翻译遵循 CC BY-SA 4.0 许可协议
这是我在我目前正在从事的项目中使用的方法。
检索 git 用户的示例: