How to use colorette - 10 common examples

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 TankerHQ / sdk-js / config / rollup-plugin-copy-edit.js View on Github external
const success = (src, dest, mode) => {
  console.log(`(${name}) '${green(src)}' -> '${green(dest)}' (${green(tick)})`); // eslint-disable-line no-console
  if (mode) {
    console.log(`(${name}) mode set to ${green(mode)} on '${green(dest)}' (${green(tick)})`); // eslint-disable-line no-console
  }
};
github solid / node-solid-server / bin / lib / cli-utils.js View on Github external
function loadConfig (program, options) {
  let argv = {
    ...options,
    version: program.version()
  }
  let configFile = argv['configFile'] || './config.json'

  try {
    const file = fs.readFileSync(configFile)

    // Use flags with priority over config file
    const config = JSON.parse(file)
    argv = { ...config, ...argv }
  } catch (err) {
    // No file exists, not a problem
    console.log(cyan(bold('TIP')), 'create a config.json: `$ solid init`')
  }

  return argv
}
github windycom / windy-plugins / compiler.js View on Github external
(async () => {
    console.log(`\nBuilding ${yellow(name)}, version ${yellow(version)}`);

    // Beginners example selection
    if (prog.prompt) {
        srcDir = await utils.prompt();
    }

    c.info(`Compiler will compile ${yellow(`./${srcDir}/plugin.html`)}`);

    reloadConfig();

    try {
        // Basic assertions
        assert(
            typeof config === 'object',
            'Missing basic config object. Make sure you have valid ' +
                'config.js in src dir'
github knex / knex / bin / cli.js View on Github external
function initKnex(env, opts) {
  checkLocalModule(env);
  if (process.cwd() !== env.cwd) {
    process.chdir(env.cwd);
    console.log(
      'Working directory changed to',
      color.magenta(tildify(env.cwd))
    );
  }

  if (!opts.knexfile) {
    const configurationPath = resolveKnexFilePath();
    const configuration = configurationPath
      ? require(configurationPath.path)
      : undefined;

    env.configuration = configuration || mkConfigObj(opts);
    if (!env.configuration.ext && configurationPath) {
      env.configuration.ext = configurationPath.extension;
    }
  }
  // If knexfile is specified
  else {
github mattallty / Caporal.js / lib / help.js View on Github external
_getCommands() {
    const commandTable = this._getSimpleTable();
    this._program._commands
      // don't include default command
      .filter((c) => c.name() !== '' && c.visible())
      .forEach(cmd => {
        commandTable.push(
          [c.magenta(cmd.getSynopsis()), cmd.description()]
        );
      });
    commandTable.push([c.magenta('help '), 'Display help for a specific command']);
    return c.bold('COMMANDS') + "\n\n" + colorize(commandTable.toString());
  }
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 mattallty / Caporal.js / lib / help.js View on Github external
_getCommands() {
    const commandTable = this._getSimpleTable();
    this._program._commands
      // don't include default command
      .filter((c) => c.name() !== '' && c.visible())
      .forEach(cmd => {
        commandTable.push(
          [c.magenta(cmd.getSynopsis()), cmd.description()]
        );
      });
    commandTable.push([c.magenta('help '), 'Display help for a specific command']);
    return c.bold('COMMANDS') + "\n\n" + colorize(commandTable.toString());
  }
github zamotany / react-slate / packages / react-slate-reflow / src / render / applyStyle.js View on Github external
/* @flow */

import colorette from 'colorette';
import memoize from 'fast-memoize';
import { withRgbColor, withRgbBackgroundColor } from './colors/rgb';
import { withHexColor, withHexBackgroundColor } from './colors/hex';
import { withKeywordColor, withKeywordBackgroundColor } from './colors/keyword';

colorette.options.enabled = process.env.CI ? true : colorette.options.enabled;

const CSI = '\u001b[';

const reset = memoize(
  (text: string) => (text ? `${CSI}0m${text}${CSI}0m` : text)
);

const capitalize = memoize(
  (text: string) => `${text[0].toUpperCase()}${text.slice(1)}`
);

const colorize = memoize(
  (color: string, isBackground: boolean, text: string) => {
    if (color === 'initial') {
      return reset(text);
    }