Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 125 lines (84 sloc) 3.317 kb
7ee61b6 Ben Alman Docs reorganization.
authored
1 [Grunt homepage](https://github.com/cowboy/grunt) | [Documentation table of contents](toc.md)
2
3 # The grunt API
4
dbaee9c Ben Alman More docs.
authored
5 Grunt exposes a lot of its functionality on the `grunt` object passed into a [config.js gruntfile](configuring.md) or [tasks file](tasks_creating.md).
6
7 In a [gruntfile](configuring.md):
8
9 ```javascript
10 exports.config = function(grunt) {
11 // Tons o' stuff is available on the grunt object.
12 };
13 ```
14
15 In a [custom tasks file](tasks_creating.md):
16
17 ```javascript
18 exports.tasks = function(grunt) {
19 // Tons o' stuff is available on the grunt object.
20 };
21 ```
22
23 ## Methods
24
25 ### Config
26
27 #### grunt.initConfig
28 This method is a convenient shortcut for the [config.init](api_config.md) method.
29
30 Usage:
31
32 ```javascript
33 grunt.initConfig(configObject);
34 ```
35
36 ### Tasks: Creating
37
38 #### grunt.registerTask
39 This method is a convenient shortcut for the [task.registerTask](api_task.md) method.
40
41 Usage:
42
43 ```javascript
44 grunt.registerTask(taskName, taskList);
45 grunt.registerTask(taskName, description, taskFunction);
46 ```
47
48 #### grunt.registerMultiTask
49 This method is a convenient shortcut for the [task.registerMultiTask](api_task.md) method.
50
51 Usage:
52
53 ```javascript
54 grunt.registerMultiTask(taskName, description, taskFunction);
55 ```
56
57 #### grunt.registerInitTask
58 This method is a convenient shortcut for the [task.registerInitTask](api_task.md) method.
59
60 Usage:
61
62 ```javascript
63 grunt.registerInitTask(taskName, description, taskFunction);
64 ```
65
66 ### Tasks: Loading
67
68 #### grunt.loadTasks
69 This method is a convenient shortcut for the [task.loadTasks](api_task.md) method.
70
71 Usage:
72
73 ```javascript
74 grunt.loadTasks();
75 ```
76
77 #### grunt.loadNpmTasks
78 This method is a convenient shortcut for the [task.loadNpmTasks](api_task.md) method.
79
80 Usage:
81
82 ```javascript
83 grunt.loadNpmTasks();
84 ```
85
86 ### Helpers
87
88 #### grunt.registerHelper
89 This method is a convenient shortcut for the [task.registerHelper](api_task.md) method.
90
91 Usage:
92
93 ```javascript
94 grunt.registerHelper(helperName, helperFunction);
95 ```
96
97 #### grunt.helper
98 This method is a convenient shortcut for the [task.helper](api_task.md) method.
99
100 Usage:
101
102 ```javascript
103 grunt.helper(helperName [, arguments...]);
104 ```
7ee61b6 Ben Alman Docs reorganization.
authored
105
106 ## Internals
107
dbaee9c Ben Alman More docs.
authored
108 * [grunt.utils](api_utils.md) - miscellaneous utilities
109 * [grunt.template](api_template.md) - template methods
110 * [grunt.task](api_task.md) - the entire task interface
111 * [grunt.file](api_file.md) - glob expansion, file reading, writing, directory traversing
112 * [grunt.fail](api_fail.md) - more serious than error logging, `fail.warn` and `fail.fatal` will halt everything
113 * [grunt.config](api_config.md) - reading values from the grunt configuration
114 * [grunt.option](api_option.md) - reading values from the command-line options
115 * [grunt.log](api_log.md) - don't use `console.log`, use `log.writeln` instead!
116 * [grunt.verbose](api_verbose.md) - just like `log`, but only logs if `--verbose` was specified.
7ee61b6 Ben Alman Docs reorganization.
authored
117
392aef1 Ben Alman Removing globals "underscore" and "async" which are now available as "ut...
authored
118 ## External libraries, exposed
119
dbaee9c Ben Alman More docs.
authored
120 * [utils.async](api_utils.md) - [Async utilities](https://github.com/caolan/async)
121 * [utils._](api_utils.md) - [Underscore.js](http://underscorejs.org/), including [Underscore.string](https://github.com/epeli/underscore.string)
122 * [utils.hooker](api_utils.md) - [JavaScript hooker](https://github.com/cowboy/javascript-hooker)
392aef1 Ben Alman Removing globals "underscore" and "async" which are now available as "ut...
authored
123
7ee61b6 Ben Alman Docs reorganization.
authored
124 Unfortunately, I haven't documented everything yet. Fortunately, the source is open and browsable. Have fun!
Something went wrong with that request. Please try again.