Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict'
const color = require('supports-color').stdout
const extensions = require('markdown-extensions')
const processor = require('remark')
module.exports = function (argv, pkg, packageOpts, files, cwd, repository) {
let reporter
let reporterOptions
if (argv.report) {
// Only take one --report option
reporter = [].concat(argv.report)[0]
if (typeof reporter !== 'string') {
// Reporter was specified with subarg syntax
reporterOptions = reporter
reporter = reporter._[0]
}
var fs = require('fs');
var path = require('path');
const supportsColor = require('supports-color');
module.exports = help;
const highlight = supportsColor.stdout ? '\x1B\[$1m' : '';
function help(item) {
if (!item) {
item = 'help';
} else if (item === true) { // if used with -h or --help and no args
item = 'help';
}
// cleanse the filename to only contain letters
// aka: /\W/g but figured this was eaiser to read
item = item.replace(/[^a-z]/gi, '');
try {
var dir = path.join(__dirname, '..', '..', 'doc', 'cli', item + '.txt');
var body = fs.readFileSync(dir, 'utf8');
return body.replace(/\\x1B\[(.)m/g, highlight);
const util = require('util');
const chalk = require('chalk');
const supportsColor = require('supports-color');
const moment = require('moment');
const { LEVEL } = require('triple-beam');
const TransportStream = require('winston-transport');
const helpers = require('./helpers');
const {colors} = require('../helpers/levelsSettings');
const _ = require('lodash');
let ansi = new chalk.constructor({level: 0});
if (supportsColor.stderr.has16m) {
ansi = new chalk.constructor({level: 3});
} else if (supportsColor.stdout.has256) {
ansi = new chalk.constructor({level: 2});
} else if (supportsColor.stdout) {
ansi = new chalk.constructor({level: 1});
}
//
// ### function Console (options)
// #### @options {Object} Options for this instance.
// Constructor function for the Console transport object responsible
// for persisting log messages and metadata to a terminal or TTY.
//
var Console = module.exports = function (options) {
options = options || {};
TransportStream.call(this, options);
this.stderrLevels = getStderrLevels(options.stderrLevels, options.debugStdout);
this.eol = os.EOL;
//
colorize(str, clazz) {
const colors = {
low: '31;1',
medium: '33;1',
high: '32;1'
};
/* istanbul ignore next: different modes for CI and local */
if (supportsColor.stdout && colors[clazz]) {
return `\u001b[${colors[clazz]}m${str}\u001b[0m`;
}
return str;
}
}
supportsColor () {
// if we've been explictly told not to support
// color then turn this off
if (process.env.NO_COLOR) {
return false
}
// https://github.com/cypress-io/cypress/issues/1747
// always return true in CI providers
if (process.env.CI) {
return true
}
// ensure that both stdout and stderr support color
return Boolean(supportsColor.stdout) && Boolean(supportsColor.stderr)
},
grunt.registerTask('colorcheck', () => {
// Writes 'true' or 'false' to the file
const supports = String(Boolean(supportsColor.stdout));
grunt.file.write('test/tmp/colors', supports);
});
(function (process){
'use strict';
const escapeStringRegexp = require('escape-string-regexp');
const ansiStyles = require('ansi-styles');
const stdoutColor = require('supports-color').stdout;
const template = require('./templates.js');
const isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm');
// `supportsColor.level` → `ansiStyles.color[name]` mapping
const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m'];
// `color-convert` models to exclude from the Chalk API due to conflicts and such
const skipModels = new Set(['gray']);
const styles = Object.create(null);
function applyOptions(obj, options) {
options = options || {};
test.serial(`should colorize the error | ${title}`, async t => {
const { stopLogging, log } = startLogging({ log: 'spy', eventName })
await emit()
t.true(log.calledOnce)
t.false(hasAnsi(String(log.firstCall.args[0])))
t.false(hasAnsi(log.firstCall.args[0].stack))
t.is(hasAnsi(inspect(log.firstCall.args[0])), Boolean(supportsColor.stdout))
stopLogging()
})
const formatter = function formatter(options) {
const body = options.message ? options.message : '';
const suffix = (options.meta && Object.keys(options.meta).length
? `\n\t${JSON.stringify(options.meta)}` : '');
const fullLog = `${body}${suffix}`;
return supportsColor.stdout ? config.colorize(options.level, fullLog) : fullLog;
};
withProcRunner(log, async (proc) => {
log.info('Deleting old output');
await del(BUILD_DIR);
const cwd = ROOT_DIR;
const env = { ...process.env };
if (supportsColor.stdout) {
env.FORCE_COLOR = 'true';
}
log.info(`Starting babel ${flags.watch ? ' in watch mode' : ''}`);
await Promise.all([
proc.run('babel ', {
cmd: 'babel',
args: [
'src',
'--ignore', `*.test.js`,
'--out-dir', relative(cwd, BUILD_DIR),
'--copy-files',
...(flags.dev ? ['--source-maps', 'inline'] : []),
...(flags.watch ? ['--watch'] : ['--quiet'])
],
wait: true,