Skip to content

Commit a1407ae

Browse files
mrjacobbloomDABH
authored andcommitted
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
1 parent acb7f66 commit a1407ae

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

README.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,27 @@ I prefer the first way. Some people seem to be afraid of extending `String.proto
9494

9595
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.
9696

97-
## Disabling Colors
97+
## Enabling/Disabling Colors
9898

99-
To disable colors you can pass the following arguments in the command line to your application:
99+
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:
100100

101101
```bash
102102
node myapp.js --no-color
103+
node myapp.js --color=false
104+
105+
node myapp.js --color
106+
node myapp.js --color=true
107+
node myapp.js --color=always
108+
109+
FORCE_COLOR=1 node myapp.js
110+
```
111+
112+
Or in code:
113+
114+
```javascript
115+
var colors = require('colors');
116+
colors.enable();
117+
colors.disable();
103118
```
104119

105120
## Console.log [string substitution](http://nodejs.org/docs/latest/api/console.html#console_console_log_data)

0 commit comments

Comments
 (0)