Document colors.enable() and .disable() (#255)

Resolves #251 requesting documentation for the enable/disable functions. This documents them in the readme. My explanation doesn't really fit the tone of the rest of the readme, so I'm open to changing the wording
This commit is contained in:
Jacob 2019-09-22 17:12:39 -06:00 committed by David Hyde
parent acb7f66738
commit a1407aee04

View File

@ -94,12 +94,27 @@ I prefer the first way. Some people seem to be afraid of extending `String.proto
If you are writing good code you will never have an issue with the first approach. If you really don't want to touch `String.prototype`, the second usage will not touch `String` native object.
## Disabling Colors
## Enabling/Disabling Colors
To disable colors you can pass the following arguments in the command line to your application:
The package will auto-detect whether your terminal can use colors and enable/disable accordingly. When colors are disabled, the color functions do nothing. You can override this with a command-line flag:
```bash
node myapp.js --no-color
node myapp.js --color=false
node myapp.js --color
node myapp.js --color=true
node myapp.js --color=always
FORCE_COLOR=1 node myapp.js
```
Or in code:
```javascript
var colors = require('colors');
colors.enable();
colors.disable();
```
## Console.log [string substitution](http://nodejs.org/docs/latest/api/console.html#console_console_log_data)