Skip to content

Commit

Permalink
feat: add --no-color
Browse files Browse the repository at this point in the history
Some terminals do not support colors and will output a bunch of
unnecessary clutter instead. This creates `-n|--no-color` which disables
color completely
  • Loading branch information
Venefilyn committed May 10, 2021
1 parent ede9189 commit e1c370f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/sirv-cli/bin.js
Expand Up @@ -19,6 +19,7 @@ sade('sirv [dir]')
.option('-G, --gzip', 'Send precompiled "*.gz" files when "gzip" is supported', true)
.option('-B, --brotli', 'Send precompiled "*.br" files when "brotli" is supported', true)
.option('-m, --maxage', 'Enable "Cache-Control" header & define its "max-age" value (sec)')
.option('-n, --no-color', 'Disables colored output')
.option('-i, --immutable', 'Enable the "immutable" directive for "Cache-Control" header')
.option('-k, --http2', 'Enable the HTTP/2 protocol. Requires Node.js 8.4.0+')
.option('-C, --cert', 'Path to certificate file for HTTP/2 server')
Expand Down
4 changes: 4 additions & 0 deletions packages/sirv-cli/index.js
Expand Up @@ -34,6 +34,10 @@ module.exports = function (dir, opts) {
dir = resolve(dir || '.');
opts.maxAge = opts.m;

if (opts.no_color) {
colors.enabled = false
}

if (opts.cors) {
opts.setHeaders = res => {
res.setHeader('Access-Control-Allow-Origin', '*');
Expand Down

0 comments on commit e1c370f

Please sign in to comment.