Skip to content

Commit

Permalink
More grunt.log documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
cowboy committed Mar 23, 2012
1 parent 2b199e7 commit e991a8f
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion docs/api_log.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ This object contains all methods of `grunt.log` but only logs if the `--verbose`
grunt.verbose.or
```

## Utility
## Utility Methods
These methods don't actually log, they just return strings that can be used in other methods.

### grunt.log.wordlist
Returns a comma-separated list of `arr` array items.
Expand All @@ -86,6 +87,28 @@ Returns a comma-separated list of `arr` array items.
grunt.log.wordlist(arr)
```

### grunt.log.uncolor
Removes all color information from a string, making it suitable for testing `.length` or perhaps logging to a file.

```javascript
grunt.log.uncolor(str)
```

### grunt.log.wraptext
Wrap `text` string to `width` characters with `\n`, ensuring that words are not split in the middle unless absolutely necessary.

```javascript
grunt.log.wraptext(width, text)
```

### grunt.log.table
Wrap `texts` array of strings to columns `widths` characters wide. A wrapper for the `grunt.log.wraptext` method that can be used to generate output in columns.

```javascript
grunt.log.table(widths, texts)
```


## An Example

A common pattern is to only log when in `--verbose` mode OR if an error occurs, like so:
Expand Down

0 comments on commit e991a8f

Please sign in to comment.