[英]Execute multiple shell commands synchronously in Node
我的工作代碼完全可以實現我想要的功能,但是我對使用的方法不滿意,因為它無法很好地擴展。
假設我要執行4個命令,一個接一個,以克隆存儲庫並將簽出到本地文件夾:
//shell command
var cmd = "cd /Users/xxxx/Documents/DESIGN" +
" && git clone https://github.com/xxxx/xxxx.git testing" +
" && cd testing" +
" && git checkout 4.0";
//execute shell command
var exec = require("child_process").exec;
exec(cmd, function(err, stdout, stderr){
if (err) console.log(err);
console.log(stdout);
});
有沒有一種方法可以干凈地執行多個命令並使其具有更高的可伸縮性,而無需僅通過&&
將它們添加到原始命令字符串中以將它們連接起來?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.