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

前端 未结 2 1654
深忆病人
深忆病人 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:11

    I found the answer to my own question by re-rereading Matthew Eernisse's post. For those wondering how to do it:

    var exec = require('child_process').exec;
    
    desc('first task');
    task('first', [], function(params) {
      exec('long running system command', function() {
        complete();
      });
    }, true); // this prevents task from exiting until complete() is called
    
    desc('second task');
    task('second', ['first'], function(params) {
      // do something dependent on the completion of 'first' task
    });
    

提交回复
热议问题