You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the `taskName` is not provided, the task will be referenced by the `name` property of a named function or a user-defined `displayName` property. The `taskName` parameter must be used for anonymous functions missing a `displayName` property.
130
59
131
-
The callback accepts an optional `Error` object. If it receives an error,
132
-
the task will fail.
60
+
Since any registered task can be run from the command line, avoid using spaces in task names.
133
61
134
-
### Return a stream
62
+
| parameter | type | note |
63
+
|:--------------:|:------:|-------|
64
+
| taskName | string | An alias for the task function within the the task system. Not needed when using named functions for `taskFunction`. |
65
+
| taskFunction <br> **(required)**| function | A [task function][tasks-concepts] or composed task - generated by `series()` and `parallel()`. Ideally a named function. [Task metadata][task-metadata-section] can be attached to provide extra information to the command line. |
135
66
136
-
```js
137
-
gulp.task('somename', function() {
138
-
returngulp.src('client/**/*.js')
139
-
.pipe(minify())
140
-
.pipe(gulp.dest('build'));
141
-
});
142
-
```
67
+
### Returns
143
68
144
-
### Return a promise
69
+
When registering a task, nothing is returned.
145
70
146
-
```js
147
-
varPromise=require('promise');
148
-
var del =require('del');
149
-
150
-
gulp.task('clean', function() {
151
-
returnnewPromise(function (resolve, reject) {
152
-
del(['.build/'], function(err) {
153
-
if (err) {
154
-
reject(err);
155
-
} else {
156
-
resolve();
157
-
}
158
-
});
159
-
});
160
-
});
161
-
```
71
+
When retrieving a task, a wrapped task (not the original function) registered as `taskName` will be returned. The wrapped task has an `unwrap()` method that will return the original function.
162
72
163
-
or:
164
-
```js
165
-
var promisedDel =require('promised-del');
73
+
### Errors
166
74
167
-
gulp.task('clean', function() {
168
-
returnpromisedDel(['.build/']);
169
-
});
170
-
```
75
+
When registering a task where `taskName` is missing and `taskFunction` is anonymous, will throw an error with the message, "Task name must be specified".
76
+
77
+
## Task metadata
171
78
172
-
### Return a child process
79
+
| property | type | note |
80
+
|:--------------:|:------:|-------|
81
+
| name | string | A special property of named functions. Used to register the task. <br> **Note:**[`name`][function-name-external] is not writable; it cannot be set or changed. |
82
+
| displayName | string | When attached to a `taskFunction` creates an alias for the task. If using characters that aren't allowed in function names, use this property. |
83
+
| description | string | When attached to a `taskFunction` provides a description to be printed by the command line when listing tasks. |
84
+
| flags | object | When attached to a `taskFunction` provides flags to be printed by the command line when listing tasks. The keys of the object represent the flags and the values are their descriptions. |
0 commit comments