gruntjs - Use npm module in Grunt registerTask -


i use npm module on new tasks, i've no result :

  grunt.registertask('done', function () {      var prepend = require('prepend');      var file = 'app.bundlees6.js',         string = '// string';      prepend(file, string, function(error) {       if (error)         console.error(error.message);       else         console.log('yeah');     });    }); 

when run grunt done, i'm not see console.log, :

running "done" task  done, without errors. 

do know how can use npm module on grunt registertask ?

thank !

the problem task it's asynchronous.

you can register asynchronous grunt tasks, have call this.async() obtain completion callback , have call callback, when task complete (passing false if task has failed).

like this:

grunt.registertask('done', function () {    var callback = this.async();   var prepend = require('prepend');    var file = 'app.bundlees6.js',       string = '// string';    prepend(file, string, function(error) {     if (error) {       console.error(error.message);       callback(false);     }     else {       console.log('yeah');       callback();     }   }); }); 

Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -