Node.js and Jake - How to call system commands synchronously within a task?

前端 未结 2 1653
深忆病人
深忆病人 2021-02-10 11:39

A Jake task executes a long-running system command. Another task depends on the first task being completely finished before starting. The \'exec\' function of \'child_process\'

2条回答
  •  心在旅途
    2021-02-10 12:15

    Just for future reference, I have a synchronous exec module with no other dependencies.

    • https://npmjs.org/package/allsync

    Example:

    var allsync = require("allsync");
    allsync.exec( "find /", function(data){
        process.stdout.write(data);
    });
    console.log("Done!");
    

    In the above exampale, Done is only printed after the find process exists. The exec function essentially blocks until complete.

提交回复
热议问题