How to use the registerTask function from grunt

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

34
35
36
37
38
39
40
41
42
43

grunt.loadTasks(path.join(__dirname, '..', 'tasks'));

let tasksDone = false;

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

grunt.task.run(['create-windows-installer', 'done']).start();
fork icon104
star icon392
watch icon21

36
37
38
39
40
41
42
43
44

grunt.registerTask(require('grunt-contrib-jshint'));
grunt.registerTask(require('grunt-contrib-concat'));
grunt.registerTask(require('grunt-contrib-uglify'), 'min'); // renomeações opcionais no segundo parâmetro

// gera um objeto "node-task" compatível e nele, executa grunt.registerTask
grunt.registerTask('name','description', function (config) {
  //...
});
fork icon134
star icon78
watch icon17

157
158
159
160
161
162
163
164
165
And all the task aliases, such as the default task, live in `node_tasks/aliases.js`:

```javascript
'use strict';
module.exports = function(grunt) {
    grunt.registerTask('default', ['less', 'autoprefixer'])
    grunt.registerTask('server', ['connect', 'watch'])
}
```
fork icon1
star icon3
watch icon3

+ 7 other calls in file

40
41
42
43
44
45
46
47
48
49
tasks/myCustomTask.js

```javascript
module.exports = function(grunt) {
  // or registerMultiTask
  grunt.registerTask('myCustomTask', 'A task that does really neat stuff', function() {
    // The neat stuff...
  });
  // You probably don't need to return configuration for tasks you write,
  // but you could use a function in a plugin's task configuration to do
fork icon1
star icon3
watch icon1

+ 7 other calls in file

143
144
145
146
147
148
149
150
151
152
};


module.exports = function (grunt) {
  // bower-install task initialization.
  grunt.registerTask('bower-install', 'Install and inject a component.', function (component) {
    var BI = bootstrap(this, grunt);

    if (helpers.is(component, 'string') && component !== '--silent') {
      installComponent(BI, component);
fork icon87
star icon0
watch icon1

+ 3 other calls in file

9
10
11
12
13
14
15
16
17
18
UpdateTask.TASK_NAME = 'bower-update-selective';

UpdateTask.TASK_DESCRIPTION = 'Grunt plugin for bower update of select components';

UpdateTask.registerWithGrunt = function (grunt) {
    grunt.registerTask(UpdateTask.TASK_NAME, UpdateTask.TASK_DESCRIPTION, function() {
        var task = new UpdateTask(this);
        task.run();
    });
};
fork icon2
star icon0
watch icon2

165
166
167
168
169
170
171
172
173
}

/*
// The main grunt task
*/
grunt.registerTask('nsp-audit', 'Audits package.json against nodesecurity.io API', function () {
    var done = this.async(),
        config = makeConfig(grunt.config.get('nsp-audit')),
        file = grunt.option('nsp-file');
fork icon0
star icon0
watch icon3

+ 31 other calls in file

12
13
14
15
16
17
18
19
20
21
module.exports = function(grunt) {

  console.log("update/tasks/wordpressupdate.js");


  grunt.registerTask('pull_site', 'pulls the files and DB from the remote server', function() {
    var target = grunt.option('target') || task_options['target'];
    if ( typeof target === "undefined" || typeof grunt.config.get('wordpressdeploy')[target] === "undefined" || target === "local")  {
      grunt.fail.warn("Invalid target specified. Did you pass the wrong argument? Please check your task configuration.", 6);
    }
fork icon0
star icon0
watch icon1

30
31
32
33
34
35
36
37
38
39
        params.unshift(grunt);
        return task.runner.apply(this, params);
      };
    }

    grunt.registerTask(taskName, task.description, taskRunner);
  });
};

module.exports = function() {
fork icon0
star icon0
watch icon20

+ 3 other calls in file