Skip to content

Commit

Permalink
Fixing a few documentation typos.
Browse files Browse the repository at this point in the history
  • Loading branch information
cowboy committed Apr 5, 2012
1 parent c161b14 commit c2b56c0
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ In the following example, a default task is defined that, when invoked by specif

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

_Note: choose the default tasks that make the most sense for your project. If you find yourself commonly executing other groups of tasks, create as many named aliases as you need!_
Expand Down
70 changes: 35 additions & 35 deletions docs/types_of_tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ Tasks can be created in a few ways.
## Alias tasks

```javascript
task.registerTask(taskName, [description, ] taskList);
grunt.registerTask(taskName, [description, ] taskList);
```

_Note that for alias tasks, the description is optional. If omitted, a useful description will be added for you automatically._

In the following example, a `theworks` task is defined that, when invoked by `grunt theworks`, will execute the `lint`, `qunit`, `concat` and `min` tasks in-order. Running `grunt theworks` behaves exactly as if `grunt lint qunit concat min` was run on the command line.

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

In this example, a default task is defined that, when invoked by `grunt` or `grunt default`, will execute the `lint`, `qunit`, `concat` and `min` tasks in-order. It behaves exactly as if `grunt lint qunit concat min` was run on the command line.

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

_In case it's not obvious, defining a `default` task is helpful because it runs by default, whenever you run `grunt` without explicitly specifying tasks._
Expand All @@ -39,7 +39,7 @@ _Note: multi tasks will ignore any config sub-properties beginning with `_` (und

```javascript
/*global config:true, task:true*/
config.init({
grunt.initConfig({
lint: {
test: ['test/*.js'],
lib: ['lib/*.js'],
Expand All @@ -52,15 +52,15 @@ While it's probably most useful for you to check out the JavaScript source of th

```javascript
/*global config:true, task:true*/
config.init({
grunt.initConfig({
logstuff: {
foo: [1, 2, 3],
bar: 'hello world',
baz: false
}
});

task.registerMultiTask('logstuff', 'This task logs stuff.', function() {
grunt.registerMultiTask('logstuff', 'This task logs stuff.', function() {
// this.target === the name of the target
// this.data === the target's value in the config object
// this.name === the task name
Expand All @@ -69,11 +69,11 @@ task.registerMultiTask('logstuff', 'This task logs stuff.', function() {
// this.file === file-specific .src and .dest properties

// Log some stuff.
log.writeln(this.target + ': ' + this.data);
grunt.log.writeln(this.target + ': ' + this.data);

// If data was falsy, abort!!
if (!this.data) { return false; }
log.writeln('Logging stuff succeeded.');
grunt.log.writeln('Logging stuff succeeded.');
});
```

Expand Down Expand Up @@ -125,33 +125,33 @@ Aborted due to warnings.
You can go crazy with tasks. If your tasks don't follow the "multi task" structure, use a custom task.

```javascript
task.registerTask('default', 'My "default" task description.', function() {
log.writeln('Currently running the "default" task.');
grunt.registerTask('default', 'My "default" task description.', function() {
grunt.log.writeln('Currently running the "default" task.');
});
```

Inside a task, you can run other tasks.

```javascript
task.registerTask('foo', 'My "foo" task.', function() {
grunt.registerTask('foo', 'My "foo" task.', function() {
// Enqueue "bar" and "baz" tasks, to run after "foo" finishes, in-order.
task.run('bar baz');
grunt.task.run('bar baz');
// Or:
task.run(['bar', 'baz']);
grunt.task.run(['bar', 'baz']);
});
```

Tasks can be asynchronous.

```javascript
task.registerTask('asyncfoo', 'My "asyncfoo" task.', function() {
grunt.registerTask('asyncfoo', 'My "asyncfoo" task.', function() {
// Force task into async mode and grab a handle to the "done" function.
var done = this.async();
// Run some sync stuff.
log.writeln('Processing task...');
grunt.log.writeln('Processing task...');
// And some async stuff.
setTimeout(function() {
log.writeln('All done!');
grunt.log.writeln('All done!');
done();
}, 1000);
});
Expand All @@ -160,8 +160,8 @@ task.registerTask('asyncfoo', 'My "asyncfoo" task.', function() {
Tasks can access their own name and arguments.

```javascript
task.registerTask('foo', 'My "foo" task.', function(a, b) {
log.writeln(this.name, a, b);
grunt.registerTask('foo', 'My "foo" task.', function(a, b) {
grunt.log.writeln(this.name, a, b);
});

// Usage:
Expand All @@ -175,27 +175,27 @@ task.registerTask('foo', 'My "foo" task.', function(a, b) {
Tasks can fail if any errors were logged.

```javascript
task.registerTask('foo', 'My "foo" task.', function() {
grunt.registerTask('foo', 'My "foo" task.', function() {
if (failureOfSomeKind) {
log.error('This is an error message.');
grunt.log.error('This is an error message.');
}

// Fail task if errors were logged.
if (task.hadErrors()) { return false; }

log.writeln('This is the success message');
grunt.log.writeln('This is the success message');
});
```

When tasks fail, all subsequent tasks will be aborted unless `--force` was specified.

```javascript
task.registerTask('foo', 'My "foo" task.', function() {
grunt.registerTask('foo', 'My "foo" task.', function() {
// Fail synchronously.
return false;
});

task.registerTask('bar', 'My "bar" task.', function() {
grunt.registerTask('bar', 'My "bar" task.', function() {
var done = this.async();
setTimeout(function() {
// Fail asynchronously.
Expand All @@ -204,18 +204,18 @@ task.registerTask('bar', 'My "bar" task.', function() {
});
```

Tasks can be dependent on the successful execution of other tasks. Note that `task.requires` won't actually RUN the other task(s). It'll just check to see that it has run and not failed.
Tasks can be dependent on the successful execution of other tasks. Note that `grunt.task.requires` won't actually RUN the other task(s). It'll just check to see that it has run and not failed.

```javascript
task.registerTask('foo', 'My "foo" task.', function() {
grunt.registerTask('foo', 'My "foo" task.', function() {
return false;
});

task.registerTask('bar', 'My "bar" task.', function() {
grunt.registerTask('bar', 'My "bar" task.', function() {
// Fail task if "foo" task failed or never ran.
task.requires('foo');
grunt.task.requires('foo');
// This code executes if the "foo" task ran successfully.
log.writeln('Hello, world.');
grunt.log.writeln('Hello, world.');
});

// Usage:
Expand All @@ -228,24 +228,24 @@ task.registerTask('bar', 'My "bar" task.', function() {
Tasks can fail if required configuration properties don't exist.

```javascript
task.registerTask('foo', 'My "foo" task.', function() {
grunt.registerTask('foo', 'My "foo" task.', function() {
// Fail task if "meta.name" config prop is missing.
config.requires('meta.name');
grunt.config.requires('meta.name');
// Also fails if "meta.name" config prop is missing.
config.requires(['meta', 'name']);
grunt.config.requires(['meta', 'name']);
// Log... conditionally.
log.writeln('This will only log if meta.name is defined in the config.');
grunt.log.writeln('This will only log if meta.name is defined in the config.');
});
```

Tasks can access configuration properties.

```javascript
task.registerTask('foo', 'My "foo" task.', function() {
grunt.registerTask('foo', 'My "foo" task.', function() {
// Log the property value. Returns null if the property is undefined.
log.writeln('The meta.name property is: ' + config('meta.name'));
grunt.log.writeln('The meta.name property is: ' + grunt.config('meta.name'));
// Also logs the property value. Returns null if the property is undefined.
log.writeln('The meta.name property is: ' + config(['meta', 'name']));
grunt.log.writeln('The meta.name property is: ' + grunt.config(['meta', 'name']));
});
```

Expand Down
2 changes: 1 addition & 1 deletion tasks/init/gruntplugin/root/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Install this grunt plugin next to your project's [grunt.js gruntfile][getting_st
Then add this line to your project's `grunt.js` gruntfile:

```javascript
task.loadNpmTasks('{%= full_name %}');
grunt.loadNpmTasks('{%= full_name %}');
```

[grunt]: https://github.com/cowboy/grunt
Expand Down

0 comments on commit c2b56c0

Please sign in to comment.