How to use the colors.red function in colors

To help you get started, we’ve selected a few 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 twosigma / git-meta / node / lib / cmd / submodule.js View on Github external
const fetcher = new SubmoduleFetcher(repo, head);

    const subName = paths[0];
    const opener = new Open.Opener(repo, null);
    const subRepo = yield opener.getSubrepo(subName, 
                                            Open.SUB_OPEN_OPTION.FORCE_OPEN);
    const metaCommit = yield repo.getCommit(metaAnnotated.id());

    // Now that we have an open submodule, we can attempt to resolve
    // `subCommittish`.

    const subAnnotated = yield GitUtil.resolveCommitish(subRepo,
                                                        subCommittish);
    if (null === subAnnotated) {
        throw new UserError(`\
Could not find ${colors.red(subCommittish)} in ${colors.blue(subName)}.\
`);
    }

    // This command could take a while; let the user know exactly what we're
    // doing.

    console.log(`\
Searching for ${colors.green(GitUtil.shortSha(subAnnotated.id().tostrS()))} \
from submodule ${colors.blue(subName)}, starting at \
${colors.green(GitUtil.shortSha(metaAnnotated.id().tostrS()))} in the \
meta-repo.`);

    const subCommit = yield subRepo.getCommit(subAnnotated.id());

    // Finally, we do the search.
github apache / incubator-weex-cli / packages / @weex / plugins / doctor / lib / doctor.js View on Github external
let color;
            results.push(validatorTask.result);
            result = this.mergeValidationResults(results);
            color =
                result.type === 0 /* missing */
                    ? colors.red
                    : result.type === 2 /* installed */
                        ? colors.green
                        : colors.yellow;
            // console.log(this.androidSdk.latestVersion.AndroidSdkVersion.sdkLevel)
            messageResult += `${color(`\n${result.leadingBox} ${validator.title}\n`)}`;
            // console.log(`${result.leadingBox} ${validator.title} is`)
            for (let message of result.messages) {
                const text = message.message.replace('\n', '\n      ');
                if (message.isError) {
                    messageResult += `${colors.red(`    ✗  ${text}`)}\n`;
                    // console.log(`    ✗  ${text}`);
                }
                else if (message.isWaring) {
                    messageResult += `${colors.yellow(`    !  ${text}`)}\n`;
                    // console.log(`    !  ${text}`);
                }
                else {
                    messageResult += `    •  ${text}\n`;
                    // console.log(`    •  ${text}`);
                }
            }
        }
        return messageResult;
    }
    mergeValidationResults(results) {
github DmitrySoshnikov / hdl-js / src / bin / hdl-js-cli.js View on Github external
function execScript(script, {verbose = false} = {}) {
  try {
    new ScriptInterpreter({
      file: script,
      workingDirectory: path.dirname(script),
    }).exec();

    if (verbose) {
      console.info(colors.green('\n\u2713 Script executed successfully!\n'));
    } else {
      console.info(colors.green('[PASS]'), path.basename(script));
    }
  } catch (e) {
    if (!verbose) {
      console.info(colors.red('[FAIL]'), path.basename(script));
      return;
    }

    if (!e.errorData) {
      console.info(`Script error:`, e);
      return;
    }

    const {header, errorList, compareTo} = e.errorData;

    console.info(colors.red('\nError executing the script:\n'));

    const pad2 = '  ';
    const pad4 = '    ';

    // Find Max line number
github alibaba / funcraft / lib / local / api-invoke.js View on Github external
const headers = {
      'content-type': 'application/octet-stream',
      'x-fc-request-id': requestId,
      'x-fc-invocation-duration': billedTime,
      'x-fc-invocation-service-version': 'LATEST',
      'x-fc-max-memory-usage': memoryUsage,
      'access-control-expose-headers': 'Date,x-fc-request-id,x-fc-error-type,x-fc-code-checksum,x-fc-invocation-duration,x-fc-max-memory-usage,x-fc-log-result,x-fc-invocation-code-version'
    };

    res.status(statusCode);

    // todo: fix body 后面多个换行的 bug
    if (errorResponse) { // process HandledInvocationError and UnhandledInvocationError
      headers['content-type'] = 'application/json';

      console.error(red(errorResponse));

      if (body.toString()) {
        headers['x-fc-error-type'] = 'HandledInvocationError';
      } else {
        headers['x-fc-error-type'] = 'UnhandledInvocationError';
        body = {
          'errorMessage': `Process exited unexpectedly before completing request (duration: ${billedTime}ms, maxMemoryUsage: ${memoryUsage}MB)`
        };
      }
    }

    res.set(headers);
    res.send(body);
  }
}
github sblaurock / crypticker / index.js View on Github external
let outputData = priceData;

  // Clear screen
  process.stdout.write('\x1Bc');
  process.stdout.write('\n');

  // Set status message for connectivity or API limit issues
  if (!priceData) {
    const lastUpdateText = colors.grey(` / Last updated ${moment(lastUpdate).fromNow()}\n\n`);

    if (_.keys(previousPriceData).length) {
      outputData = previousPriceData;
    }

    if (limitReached) {
      statusOutput = colors.red(' ⚠ API limit has been reached') + lastUpdateText;
    } else {
      statusOutput = colors.red(' ⚠ Data retrieval error') + lastUpdateText;
    }

    retrievalError = true;
  } else if (allowance && allowance.remaining < 100000000) {
    statusOutput = colors.yellow(' ⚠ API limit is close to being reached\n\n');
    retrievalError = false;
  } else {
    lastUpdate = +Date.now();
    statusOutput = '';
    retrievalError = false;
  }

  const sortedPrimaryCurrencies = _.keys(outputData).sort();
github Slynova-Org / sharelove / index.js View on Github external
#!/usr/bin/env node

const got = require('got')
const { join } = require('path')
const colors = require('colors')
const emoji = require('node-emoji')
const { dependencies, devDependencies } = require(join(process.cwd(), 'package.json'))

const aliases = {}
const notStarred = {}
const cannotStar = []
const allDependencies = Object.keys({ ...dependencies, ...devDependencies })

if (!process.env.GITHUB_API_TOKEN) {
  console.log(colors.red(`${emoji.get('warning')}  We use GITHUB_API_TOKEN environment variable to call the Github API.`))
  console.log(colors.red(`Please run ${colors.bold('export GITHUB_API_TOKEN="YOUR_TOKEN"')} and try again.`))
  process.exit()
}

async function callGithubApi (query) {
  const { body } = await got.post('https://api.github.com/graphql', {
    body: { query },
    headers: { authorization: `Bearer ${process.env.GITHUB_API_TOKEN}` },
    json: true,
  })

  return body.data
}

async function fetchPackagesInformation () {
  const { body } = await got.post('https://api.npms.io/v2/package/mget', {
    body: allDependencies,
github hevans90 / oa3-api-defender / src / oa3-def.ts View on Github external
#!/usr/bin/env node

import * as colors from 'colors';
import { SpecValidator } from './spec-validator';
import * as commander from 'commander';

const getVersion = (): string => {
  return require('../package.json').version
    ? require('../package.json').version
    : 'No version found!';
};

const version = getVersion();

console.log('\n');
console.log(colors.bgBlue(colors.red('                             ')));
console.log(colors.bgBlue(colors.bold('====  OA3 API Defender   ====')));
console.log(colors.bgBlue(colors.bold('_____________________________')));
console.log(colors.bold(`v${version}`));
console.log('\n');

commander.version(version).description('Open API 3 Defender!');

commander
  .command('validate')
  .option('--specPath ', 'Absolute path to a valid OA3 Specification')
  .option('--url ', 'Fully qualified URL of the API to interrogate')
  .option(
    '--auth ',
    'String to be added as an Authorization header to requests',
  )
  .description('Validate an API versus an OA3 Spec')
github zswang / jdists / processor-extend / processor-less.js View on Github external
}, function (error, output) {
    if (error) {
      console.error(colors.red(error));
      return content;
    }
    else {
      content = output.css;
    }
  });
  return content;
github hubtype / botonic / packages / botonic-nlu / src / file-utils.js View on Github external
export async function downloadFileToDisk({ url, downloadPath }) {
  try {
    const fileWriter = fs.createWriteStream(downloadPath)
    let downloadedFile = await axios.get(url, { responseType: 'stream' })
    downloadedFile.data.pipe(fileWriter)
    return new Promise((resolve, reject) => {
      fileWriter.on('finish', resolve)
      fileWriter.on('error', reject)
    })
  } catch (e) {
    console.log(colors.red(`Error downloading the file.`))
    console.log(colors.red(`${e.response.status}: ${e.response.statusText}`))
  }
}
github daniel-lundin / kuta / src / reporters / progress.js View on Github external
failingTests.forEach(failingTest => {
        logger.log(colors.red(colors.bold(fullDescription(failingTest))));
        logger.log(colors.red(failingTest.details));
        logger.log("                              ");
      });
    }