Running a command in a Grunt Task

后端 未结 6 1992
借酒劲吻你
借酒劲吻你 2020-12-02 07:43

I\'m using Grunt (task-based command line build tool for JavaScript projects) in my project. I\'ve created a custom tag and I am wondering if it is possible to run a command

6条回答
  •  温柔的废话
    2020-12-02 08:05

    If you are using the latest grunt version (0.4.0rc7 at the time of this writing) both grunt-exec and grunt-shell fail (they don't seem to be updated to handle the latest grunt). On the other hand, child_process's exec is async, which is a hassle.

    I ended up using Jake Trent's solution, and adding shelljs as a dev dependency on my project so I could just run tests easily and synchronously:

    var shell = require('shelljs');
    
    ...
    
    grunt.registerTask('jquery', "download jquery bundle", function() {
      shell.exec('wget http://jqueryui.com/download/jquery-ui-1.7.3.custom.zip');
    });
    

提交回复
热议问题