How to use the ansi-colors.redBright function in ansi-colors

To help you get started, we’ve selected a few ansi-colors 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 sastraxi / pgsh / src / cmd / migrate / knex / down.js View on Github external
const thisDbMigration = appliedMigrations.find(m => m.name === vcsMigrations[i].name);
    if (!thisDbMigration) {
      console.error(
        `Trying to cascade deletion but migration ${c.redBright(vcsMigrations[i].name)} `
          + 'could not be found in the database! Exiting.',
      );
      endProgram(1);
    }

    // execute the migration in our database and record it in the knex migrations table
    const { name, fullPath } = vcsMigrations[i];
    const { down: runDownMigration } = require(fullPath);
    try {
      await runDownMigration(knex, Promise);
      await deleteMigration(knex, thisDbMigration.id);
      console.log(`↓ ${c.redBright(name)}`);
    } catch (err) {
      console.error(`something went wrong running down from: ${fullPath}`);
      console.error(err);
    }
  }
  /* eslint-enable no-await-in-loop  */
  /* eslint-enable import/no-dynamic-require */

  // close our database connection
  await printLatest();
  return new Promise(resolve =>
    knex.destroy(() => {
      debug(`Down-migration to <${userInput}> finished!`);
      resolve();
    }));
};
github sastraxi / pgsh / src / cmd / clone.js View on Github external
if (source === target) {
    console.log('Cannot clone a database over itself.');
    return endProgram(2);
  }

  const targetExists = await db.isValidDatabase(target);
  if (targetExists) {
    const interruptHandler = () => {
      console.log(`\nDid not drop ${target}!`);
      return endProgram(0);
    };

    console.log(`The ${target} database already exists.`);
    try {
      if (!force) {
        await confirm(c.redBright('Type the database name to drop it: '), target);
      }

      // wait for the database to be unused, then drop it
      await waitFor(db, target, interruptHandler);
      const knex = db.connectAsSuper(db.fallbackUrl()); // createdb
      await knex.raw(`drop database "${target}"`);
      await new Promise(resolve => knex.destroy(resolve));

      console.log(c.redBright(`Dropped ${target}!`));
    } catch (err) {
      console.error('reason:', err);
      console.log('Not dropping.');
      return endProgram(0);
    }
  }
github sastraxi / pgsh / src / cmd / clone.js View on Github external
return endProgram(0);
    };

    console.log(`The ${target} database already exists.`);
    try {
      if (!force) {
        await confirm(c.redBright('Type the database name to drop it: '), target);
      }

      // wait for the database to be unused, then drop it
      await waitFor(db, target, interruptHandler);
      const knex = db.connectAsSuper(db.fallbackUrl()); // createdb
      await knex.raw(`drop database "${target}"`);
      await new Promise(resolve => knex.destroy(resolve));

      console.log(c.redBright(`Dropped ${target}!`));
    } catch (err) {
      console.error('reason:', err);
      console.log('Not dropping.');
      return endProgram(0);
    }
  }

  /* eslint-disable max-len */
  let shouldSwitch = (source === currentDb);  // by default, only switch if we're cloning the current db
  if (s !== undefined) shouldSwitch = s;      // user has explicitly decided via -s, --switch
  if (S !== undefined) shouldSwitch = !S;     // user has explicitly decided via -S, --no-switch
  /* eslint-enable max-len */

  console.log(`Going to clone ${source} to ${target}...`);
  try {
    await clone(source, target);
github cleverage / daltons / index.js View on Github external
.check(function(argv) {
    // waiting for https://github.com/yargs/yargs/issues/1079
    if (argv.minviewport !== undefined && isNaN(argv.minviewport)) {
      throw new Error(
        color.red(`Error: ${color.redBright('minviewport')} must be a number`),
      )
    }
    if (argv.minviewport < 0) {
      throw new Error(
        color.red(`Error: ${color.redBright('minviewport')} must be >= 0`),
      )
    }
    if (argv.maxviewport !== undefined && isNaN(argv.maxviewport)) {
      throw new Error(
        color.red(`Error: ${color.redBright('maxviewport')} must be a number`),
      )
    }
    if (argv.maxviewport < argv.minviewport) {
      throw new Error(
        color.red(
          `Error: ${color.redBright(
            'maxviewport',
          )} must be greater than minviewport`,
        ),
      )
    }
github sastraxi / pgsh / src / cmd / migrate / knex / force-down.js View on Github external
appliedMigrations.map(m => m.name), userInput,
  );
  const prefix = appliedMigrations[idx].name.split('_')[0];

  let migrationsToDelete;
  try {
    migrationsToDelete = await knex.raw(`
      select
        name,
        migration_time::text as migratedAt
      from ${SCHEMA}.${TABLE}
      where split_part(name, '_', 1) > ?
    `, [prefix]).then(({ rows }) => rows);
  } catch (err) {
    const { message } = err;
    console.error(`postgres: ${c.redBright(message)}`);
    endProgram(1);
  }

  if (!migrationsToDelete.length) {
    console.error(
      'No migrations to forget! This usually means',
      'your database is <= the given version.',
    );
    return endProgram(2);
  }

  console.log(`This will forceably downgrade your database to ${prefix}`);
  console.log('After doing this, you should manually downgrade the actual database data / schema.\n');
  console.log('The following migrations will be forgotten:');
  const rows = migrationsToDelete.map(({ name, migratedAt }) => ([
    '*',
github cleverage / daltons / src / cli.js View on Github external
if (
      argv.destFile &&
      fs.existsSync(path.resolve(currentPath, argv.destFile))
    ) {
      throw new Error(
        color.red(
          `Error: file ${argv.destFile} set with ${color.redBright(
            'destFile',
          )} already exists`,
        ),
      )
    }
    if (!argv.destFile && !argv.verbose) {
      throw new Error(
        color.red(
          `Error: data should be either saved in a file (${color.redBright(
            'destFile',
          )} and/or output to the console (${color.redBright('verbose')})`,
        ),
      )
    }
    return true
  })
  .alias('h', 'help')
github sastraxi / pgsh / src / cmd / migrate / knex / force-down.js View on Github external
const rows = migrationsToDelete.map(({ name, migratedAt }) => ([
    '*',
    `${c.greenBright(timestamp(migratedAt))}`,
    `${c.redBright(name)}`,
  ]));
  printTable(rows);
github cleverage / daltons / src / cli.js View on Github external
)
    }
    if (argv.minViewport < 0) {
      throw new Error(
        color.red(`Error: ${color.redBright('minViewport')} must be >= 0`),
      )
    }
    if (argv.maxViewport !== undefined && isNaN(argv.maxViewport)) {
      throw new Error(
        color.red(`Error: ${color.redBright('maxViewport')} must be a number`),
      )
    }
    if (argv.maxViewport < argv.minViewport) {
      throw new Error(
        color.red(
          `Error: ${color.redBright(
            'maxViewport',
          )} must be greater than minViewport`,
        ),
      )
    }
    if (isNaN(argv.delay)) {
      throw new Error(
        color.red(`Error: ${color.redBright('delay')} must be a number`),
      )
    }
    if (argv.delay < 0) {
      throw new Error(
        color.red(`Error: ${color.redBright('delay')} must be >= 0`),
      )
    }
    if (
github cleverage / daltons / src / cli.js View on Github external
}
    if (
      argv.variationsFile &&
      fs.existsSync(path.resolve(currentPath, argv.variationsFile))
    ) {
      throw new Error(
        color.red(
          `Error: file ${argv.variationsFile} set with ${color.redBright(
            'variationsFile',
          )} already exists`,
        ),
      )
    }
    if (isNaN(argv.widthsNumber)) {
      throw new Error(
        color.red(`Error: ${color.redBright('widthsNumber')} must be a number`),
      )
    }
    if (
      argv.destFile &&
      fs.existsSync(path.resolve(currentPath, argv.destFile))
    ) {
      throw new Error(
        color.red(
          `Error: file ${argv.destFile} set with ${color.redBright(
            'destFile',
          )} already exists`,
        ),
      )
    }
    if (!argv.destFile && !argv.verbose) {
      throw new Error(
github cleverage / daltons / index.js View on Github external
}
    if (
      argv.variationsfile &&
      fs.existsSync(path.resolve(currentPath, argv.variationsfile))
    ) {
      throw new Error(
        color.red(
          `Error: file ${argv.variationsfile} set with ${color.redBright(
            'variationsfile',
          )} already exists`,
        ),
      )
    }
    if (isNaN(argv.widthsnumber)) {
      throw new Error(
        color.red(`Error: ${color.redBright('widthsnumber')} must be a number`),
      )
    }
    if (
      argv.destfile &&
      fs.existsSync(path.resolve(currentPath, argv.destfile))
    ) {
      throw new Error(
        color.red(
          `Error: file ${argv.destfile} set with ${color.redBright(
            'destfile',
          )} already exists`,
        ),
      )
    }
    if (!argv.destfile && !argv.verbose) {
      throw new Error(

ansi-colors

Easily add ANSI colors to your text and symbols in the terminal. A faster drop-in replacement for chalk, kleur and turbocolor (without the dependencies and rendering bugs).

MIT
Latest version published 2 years ago

Package Health Score

74 / 100
Full package analysis