How to use the task function from grunt

Find comprehensive JavaScript grunt.task code examples handpicked from public code repositorys.

38
39
40
41
42
43
44
45
46
47

grunt.registerTask('done', 'done', function () {
  tasksDone = true;
});

grunt.task.run(['create-windows-installer', 'done']).start();

waitsFor(30000, function () {
  return tasksDone;
});
fork icon104
star icon392
watch icon21

32
33
34
35
36
37
38
39
40
41
  }
});

// Hook into grunt.task.init to load the built-in init task.
hooker.hook(grunt.task, 'init', function() {
  grunt.task.loadTasks(asset('tasks'));
});

var name;
if (grunt.cli.tasks.length === 0) {
fork icon71
star icon191
watch icon0

+ 5 other calls in file

47
48
49
50
51
52
53
54
55
56

grunt.task.init([]);

process.chdir(oldCwd);

var gruntTasks = grunt.task._tasks,
  finalTasks = {};

var registerGruntTask = function (name) {
  finalTasks[opt.prefix + name] = function (cb) {
fork icon22
star icon167
watch icon4

+ 3 other calls in file

80
81
82
83
84
85
86
87
88
89

  updateChanges(changes);
}

function copyCards(value){
  grunt.task.run('copy:cards');
  return value;
}

function buildCard(card) {
fork icon12
star icon79
watch icon19

+ 3 other calls in file

52
53
54
55
56
57
58
59
60
61
/*
  run grunt init task
*/

function runTask() {
  grunt.task.loadTasks(path.join(__dirname, '../node_modules/grunt-init/tasks'));
  // fix windows directory by replace C:\ to C\:\
  var taskName = 'init:' + template.replace(/^([a-zA-Z]):\\/, '$1\\:\\');
  grunt.cli.tasks = [taskName];
  grunt.cli({});
fork icon3
star icon5
watch icon10

64
65
66
67
68
69
70
71
72
// }

function displayTasks(name, tasksList) {
  var tasks = tasksList.map(function(name) {
    col1len = Math.max(col1len, name.length);
    var info = grunt.task._tasks[name].info;

    return [name, info.blue];
  });
fork icon0
star icon4
watch icon2

+ 3 other calls in file

78
79
80
81
82
83
84
85
86
87
    index.registerTasks(this.settings, grunt);
});

it('should register local tasks', function() {
    grunt.task.exists('foo1').should.be.ok;
    grunt.task.exists('foo2').should.be.ok;
});

it('should append tasks to settings config', function() {
    this.settings.config.copy.should.have.properties('foo1', 'foo2');
fork icon0
star icon2
watch icon2

+ 35 other calls in file

91
92
93
94
95
96
97
98
99
  };
});

var tasks = map(enyoTasks, grunt.task._tasks);
var inits = map(enyoInits, initDefs);
var bowers = map(enyoBowers, grunt.task._tasks);
var opts = map(enyoOptions, grunt.cli.optlist, true);

function displayTasks(header, tasks) {
fork icon7
star icon10
watch icon5

+ 7 other calls in file

87
88
89
90
91
92
93
94
95
96
    });
});

describe('#registerTasks', function() {
    after(function() {
        grunt.task.renameTask('foo1', 'foo1#task.registerTasks');
    });

    it('should register all grunt tasks', function() {
        grunt.task.exists('foo1').should.not.be.ok;
fork icon0
star icon2
watch icon2

+ 5 other calls in file

77
78
79
80
81
82
83
84
85
86
  process.send({
    fail: 'fatal',
    error: errorToObject(e),
    errcode: errcode
  });
  grunt.task.clearQueue();
  grunt.util.exit(typeof errcode === 'number' ? errcode : grunt.fail.code.FATAL_ERROR);
};

grunt.fail.warn = function (e, errcode) {
fork icon3
star icon0
watch icon62

+ 9 other calls in file

4
5
6
7
8
9
10
11
12
var Stream = require('stream');


module.exports = {
    getTasks: function(filename, taskArray) {
        var oldGruntRegisterTask = grunt.task.registerTask;
        var origDir = process.cwd();
        process.chdir(path.dirname(filename));
        var gruntfile = require(filename);
fork icon0
star icon0
watch icon7

+ 3 other calls in file

20
21
22
23
24
25
26
27
28
29
  grunt.fail.warn("Invalid target specified. Did you pass the wrong argument? Please check your task configuration.", 6);
}

console.log("pulling site from " + target);
// Pull database
grunt.task.run('pull_db');
// Pulls WordPress files. Also pulls wp-content files if no repo is specified
grunt.task.run('pull_files');
if (git_repo) {
  grunt.task.run('sshexec:git_status');
fork icon0
star icon0
watch icon1

+ 5 other calls in file