How to use the colorette.gray function in colorette

To help you get started, we’ve selected a few colorette examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github windycom / windy-plugins / compiler.js View on Github external
// Save plugin to dest directory
    const destination = join(__dirname, 'dist', 'plugin.js');

    // Babel traspile
    if (prog.transpile) {
        c.info('Transpiling with babel');
        let res = await babel.transformAsync(output, {
            presets: ['@babel/preset-env'],
        }); // => Promise<{ code, map, ast }>
        output = res.code;
    }

    await fs.outputFile(destination, output);

    c.success(
        `Your plugin ${gray(name)} has been compiled to ${gray(destination)}`
    );
}
github paulmillr / loggy / index.js View on Github external
const today = () => new Date().setHours(0, 0, 0, 0);
const capitalize = str => str.charAt(0).toUpperCase() + str.slice(1);

const prettifyErrors = err => {
  if (!(err instanceof Error)) return err;
  if (!logger.dumpStacks) return err.message + stackSuppressed;

  const stack = err.stack.slice(err.stack.indexOf('\n'));
  const color = colorette[logger.dumpStacks] || colorette.gray;

  return err.message + color(stack);
};

const bell = '\x07';
const initTime = today();
const stackSuppressed = colorette.gray('\nStack trace was suppressed. Run with `LOGGY_STACKS=1` to see the trace.');

const logger = {
  // Enables or disables system notifications for errors.
  notifications: {
    app: 'Loggy',
    icon: `${__dirname}/logo.png`,
    levels: ['error'],
    notify,
  },

  // Colors that will be used for various log levels.
  colors: {
    error: 'red',
    warn: 'yellow',
    log: 'cyan',
    info: 'green',
github windycom / windy-plugins / compiler.js View on Github external
'Your repository (and also your published npm package) ' +
                'must be named "windy-plugin-AnyOfYourName".' +
                ' Change the name in your package.json'
        );

        // Tasks
        if (prog.watch || prog.build) {
            await build();
        }

        if (prog.serve) {
            await startServer();
        }

        if (prog.watch) {
            c.start(`Staring watch on ${gray(srcDir)} and ${gray('package.json')}...`);
            chokidar.watch([srcDir, 'package.json']).on('change', onChange);
        }
    } catch (e) {
        c.error(`Error\u0007`, e);
    }
})();
github morishitter / stylefmt / bin / cli.js View on Github external
function handleDiff (file, original, formatted) {
  var diff
  var color = require('colorette')

  if (original === formatted) {
    diff = 'There is no difference with the original file.'
  }

  if (color.enabled) {
    file = color.blue(file)
    if(diff) {
      diff = color.gray(diff)
    } else {
      var JsDiff = require('diff')
      diff = JsDiff.createPatch(file, original, formatted)
      diff = diff.split('\n').splice(4).map(function (line) {
        if (line[0] === '+') {
          line = color.green(line)
        } else if (line[0] === '-') {
          line = color.red(line)
        } else if (line.match(/^@@\s+.+?\s+@@/) || '\\ No newline at end of file' === line) {
          line = ''
        }
        return color.gray(line)
      })
      diff = diff.join('\n').trim()
    }
  } else if (!diff) {
github windycom / windy-plugins / compiler.js View on Github external
const onChange = async fullPath => {
    c.info(`watch: File changed ${gray(fullPath)}`);

    reloadConfig();

    await build();
};
github SlexAxton / css-colorguard / lib / formatter.js View on Github external
return filename + table(messages.map(function (msg) {
    var last = msg.text.lastIndexOf('(');
    var warning = msg.text.slice(0, last).trim();
    var position = msg.text.slice(last, msg.text.length);
    return [
      '',
      gray('line ' + msg.node.source.start.line),
      gray('col ' + msg.node.source.start.column),
      warning,
      gray(position)
    ];
  })) + collisions(messages);
};
github mattallty / Caporal.js / lib / help.js View on Github external
options.forEach(a => {
        const def = a.hasDefault() ? 'default: ' + JSON.stringify(a.default()) : '';
        const req = a.isRequired() ? c.bold('required') : c.gray('optional');
        optionsTable.push([a.synopsis(), a.description(), req, c.gray(def)])
      });
      help += optionsTable.toString();