<commit_before>[Grunt homepage](https://github.com/cowboy/grunt) | [Documentation table of contents](toc.md)

# [The grunt API](api.md) / grunt.task

Underscore.js template processing and other template-related methods.

See the [task lib source](../lib/grunt/task.js) for more information.

task.registerTask
task.registerMultiTask
task.registerInitTask
task.renameTask

task.current

task.registerHelper
task.renameHelper
task.helper

task.loadTasks
task.loadNpmTasks


task.directive
task.getDirectiveParts

task.run
task.clearQueue
task.requires
task.runAllTargets

task.hadErrors



## The task API

Note that many of these methods are available directly on the `grunt` object.


## Creating Tasks


### grunt.task.registerTask *
Register an "alias task" or a task function. This method supports the following two signatures:

**Alias task**

If a string `taskList` is specified, the new task will be an alias for one or more other tasks. Whenever this "alias task" is run, every specified task in `taskList` will be run, in the order specified.

```javascript
grunt.task.registerTask(taskName, taskList)
```

This example alias task defines a "default" task whereby the "lint", "qunit", "concat" and "min" tasks are run automatically if grunt is executed without any tasks specified:

```javascript
task.registerTask('default', 'lint qunit concat min');
```

**Function task**

If a `description` and `taskFunction` are passed, the specified function will be executed whenever the task is run. In addition, the specified description will be shown when `grunt --help` is run. Task-specific properties and methods are available inside the task function as properties of the `this` object.

Note that the `grunt.task.registerMultiTask` method, explained below, can be used to define a special type of task known as a "multi task."

```javascript
grunt.task.registerTask(taskName, description, taskFunction)
```

This example task logs `foo, testing 123` if grunt is run via `grunt foo:testing:123`. If the task is run without arguments as `grunt foo` the task logs `foo, no args`.

```javascript
grunt.task.registerTask('foo', 'A sample task that logs stuff.', function(arg1, arg2) {<commit_msg>More docs.<commit_after>[Grunt homepage](https://github.com/cowboy/grunt) | [Documentation table of contents](toc.md)

# [The grunt API](api.md) / grunt.task

Underscore.js template processing and other template-related methods.

See the [task lib source](../lib/grunt/task.js) for more information.

task.registerTask
task.registerMultiTask
task.registerInitTask
task.renameTask

task.current

task.registerHelper
task.renameHelper
task.helper

task.loadTasks
task.loadNpmTasks


task.directive
task.getDirectiveParts

task.run
task.clearQueue
task.requires
task.runAllTargets

task.hadErrors



## The task API

Note that many of these methods are available directly on the `grunt` object.


## Creating Tasks


### grunt.task.registerTask ☃
Register an "alias task" or a task function. This method supports the following two signatures:

**Alias task**

If a string `taskList` is specified, the new task will be an alias for one or more other tasks. Whenever this "alias task" is run, every specified task in `taskList` will be run, in the order specified.

```javascript
grunt.task.registerTask(taskName, taskList)
```

This example alias task defines a "default" task whereby the "lint", "qunit", "concat" and "min" tasks are run automatically if grunt is executed without any tasks specified:

```javascript
task.registerTask('default', 'lint qunit concat min');
```

**Function task**

If a `description` and `taskFunction` are passed, the specified function will be executed whenever the task is run. In addition, the specified description will be shown when `grunt --help` is run. Task-specific properties and methods are available inside the task function as properties of the `this` object.

Note that the `grunt.task.registerMultiTask` method, explained below, can be used to define a special type of task known as a "multi task."

```javascript
grunt.task.registerTask(taskName, description, taskFunction)
```

This example task logs `foo, testing 123` if grunt is run via `grunt foo:testing:123`. If the task is run without arguments as `grunt foo` the task logs `foo, no args`.

```javascript
grunt.task.registerTask('foo', 'A sample task that logs stuff.', function(arg1, arg2) {
{'fraction_non_alphanumeric': 0.09173685408604598, 'fraction_numerical': 0.003642157978602322, 'mean_word_length': 4.9620081411126185, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2046543', 'n_tokens_mistral': 1268, 'n_tokens_neox': 1225, 'n_words': 534}