Kikobeats / finepack

Organizes and maintains readable your JSON files.
MIT License
19 stars 7 forks source link

Disable chalk colors when using API? #10

Closed pdehaan closed 9 years ago

pdehaan commented 9 years ago

I'm using the API example from the README file, and notice that my output has all the chalk color codes sprinkled through the messages. Not sure if there is a flag or setting to disable the colors when I'm using the API instead of having to pass the --no-color flag via the CLI.

$ node index
[ error: [],
  warning: [ '\u001b[33mwarning\u001b[39m: \u001b[90mmissing \'bugs\'\u001b[39m',
    '\u001b[33mwarning\u001b[39m: \u001b[90mmissing \'keywords\'\u001b[39m',
    '\u001b[33mwarning\u001b[39m: \u001b[90mmissing \'homepage\'\u001b[39m',
    '\u001b[33mwarning\u001b[39m: \u001b[90mmissing \'repository\'\u001b[39m' ],
  success: [],
  info: [ '\u001b[90minfo\u001b[39m: \u001b[1mpackage.json\u001b[22m is near to be \u001b[1mfine\u001b[22m. Check the file and run again.' ] ]

Versus:

$ node index --no-color
[ error: [],
  warning: [ 'warning: missing \'bugs\'',
    'warning: missing \'keywords\'',
    'warning: missing \'homepage\'',
    'warning: missing \'repository\'' ],
  success: [],
  info: [ 'info: package.json is near to be fine. Check the file and run again.' ] ]
pdehaan commented 9 years ago

Maybe something like this (passing in a boolean colors value into the finepack options arg). Not sure if there is an easy way to default colors to true for the CLI and false for the API.

var options = {
  filename: filename,
  lint: true,
  colors: false
}

finepack(filedata, options, function(err, output, messages){
  if (err) {...}
});
Kikobeats commented 9 years ago

Give me 24h for do it :-)

On Monday, March 9, 2015, Peter deHaan notifications@github.com wrote:

Maybe something like this (passing in a boolean colors value into the finepack options arg). Not sure if there is an easy way to default colors to true for the CLI and false for the API.

var options = { filename: filename, lint: true, colors: false }

finepack(filedata, options, function(err, output, messages){ if (err) {...} });

— Reply to this email directly or view it on GitHub https://github.com/Kikobeats/finepack/issues/10#issuecomment-77913063.

pdehaan commented 9 years ago

You're awesome!

Kikobeats commented 9 years ago

check the new 2.1.0 tagged version. I updated the documentation as well (changes in the code here).

If you detect a bug, please report it! :-)