本文整理汇总了TypeScript中chalk.redBright函数的典型用法代码示例。如果您正苦于以下问题:TypeScript redBright函数的具体用法?TypeScript redBright怎么用?TypeScript redBright使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了redBright函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1:
(key, options) => {
if (argv[key] === undefined && isRequiredOption(options)) {
if (!validationError) {
validationError = `\n${chalk.bold.red('Error(s):')}`;
}
validationError = `${validationError}\n Required option '${chalk.redBright(key)}' not provided`;
}
},
开发者ID:dojo,项目名称:cli,代码行数:8,代码来源:validation.ts
示例2: start
async function start() {
const logger = await Logger('Launcher')
logger.info(chalk`========================================
{bold ${center(`Botpress Server`, 40)}}
{dim ${center(`Version ${sdk.version}`, 40)}}
{dim ${center(`OS ${process.distro.toString()}`, 40)}}
========================================`)
global.printErrorDefault = err => {
logger.attachError(err).error('Unhandled Rejection')
}
const modules: sdk.ModuleEntryPoint[] = []
const globalConfig = await Config.getBotpressConfig()
const loadingErrors: Error[] = []
let modulesLog = ''
const resolver = new ModuleResolver(logger)
for (const entry of globalConfig.modules) {
try {
if (!entry.enabled) {
modulesLog += os.EOL + `${chalk.dim('⊝')} ${entry.location} ${chalk.gray('(disabled)')}`
continue
}
const moduleLocation = await resolver.resolve(entry.location)
const rawEntry = resolver.requireModule(moduleLocation)
const entryPoint = ModuleLoader.processModuleEntryPoint(rawEntry, entry.location)
modules.push(entryPoint)
process.LOADED_MODULES[entryPoint.definition.name] = moduleLocation
modulesLog += os.EOL + `${chalk.greenBright('⦿')} ${entry.location}`
} catch (err) {
modulesLog += os.EOL + `${chalk.redBright('⊗')} ${entry.location} ${chalk.gray('(error)')}`
loadingErrors.push(new FatalError(err, `Fatal error loading module "${entry.location}"`))
}
}
logger.info(`Using ${chalk.bold(modules.length.toString())} modules` + modulesLog)
for (const err of loadingErrors) {
logger.attachError(err).error('Error starting Botpress')
}
if (loadingErrors.length) {
process.exit(1)
}
await Botpress.start({ modules }).catch(err => {
logger.attachError(err).error('Error starting Botpress')
process.exit(1)
})
logger.info(`Botpress is ready at http://${process.HOST}:${process.PORT}/`)
}
开发者ID:alexsandrocruz,项目名称:botpress,代码行数:57,代码来源:bootstrap.ts
示例3: formatMissingCommandHelp
function formatMissingCommandHelp(groupMap: GroupMap, fullCommand: string) {
const nonexistant = chalk.bold(
chalk.red(`Specified command '`) +
chalk.redBright(fullCommand) +
chalk.red(`' does not exist, please see available commands below.`)
);
return `${formatHeader()}
${nonexistant}
${mainHelp(groupMap)}
`;
}
开发者ID:dojo,项目名称:cli,代码行数:12,代码来源:help.ts
示例4: alegri
public alegri(message: string): void {
this.outputLog(chalk.redBright(message));
}
开发者ID:toxictrash,项目名称:AlegriCLI,代码行数:3,代码来源:log.ts
示例5: start
async function start() {
let currentEdition = BotpressEditions[process.BOTPRESS_EDITION] + ' Edition'
if (process.BOTPRESS_EDITION === 'ce') {
currentEdition = chalk.cyan(currentEdition)
} else {
currentEdition = chalk.yellow(currentEdition)
}
const logger = await Logger('Launcher')
logger.info(chalk`========================================
{bold ${center(`Botpress Server - ${currentEdition}`, 40)}}
{dim ${center(`Version ${sdk.version}`, 40)}}
========================================`)
global.printErrorDefault = err => {
logger.attachError(err).error('Unhandled Rejection')
}
const modules: sdk.ModuleEntryPoint[] = []
const globalConfig = await Config.getBotpressConfig()
const loadingErrors: Error[] = []
let modulesLog = ''
const resolver = new ModuleResolver(logger)
for (const entry of globalConfig.modules) {
let originalRequirePaths: string[] = []
try {
if (!entry.enabled) {
modulesLog += os.EOL + `${chalk.dim('⊝')} ${entry.location} ${chalk.gray('(disabled)')}`
continue
}
const moduleLocation = await resolver.resolve(entry.location)
// We bump temporarily bump the module's node_modules in priority
// So that it loads the local versions of its own dependencies
originalRequirePaths = global.require.getPaths()
global.require.overwritePaths([
path.join(moduleLocation, 'node_production_modules'),
path.join(moduleLocation, 'node_modules'),
...originalRequirePaths
])
const req = require(moduleLocation)
global.require.overwritePaths(originalRequirePaths)
originalRequirePaths = []
const rawEntry = (req.default ? req.default : req) as sdk.ModuleEntryPoint
const entryPoint = ModuleLoader.processModuleEntryPoint(rawEntry, entry.location)
modules.push(entryPoint)
process.LOADED_MODULES[entryPoint.definition.name] = moduleLocation
modulesLog += os.EOL + `${chalk.greenBright('⦿')} ${entry.location}`
} catch (err) {
modulesLog += os.EOL + `${chalk.redBright('⊗')} ${entry.location} ${chalk.gray('(error)')}`
loadingErrors.push(new FatalError(err, `Fatal error loading module "${entry.location}"`))
} finally {
if (originalRequirePaths.length) {
global.require.overwritePaths(originalRequirePaths)
}
}
}
logger.info(`Using ${chalk.bold(modules.length.toString())} modules` + modulesLog)
for (const err of loadingErrors) {
logger.attachError(err).error('Error starting Botpress')
}
if (loadingErrors.length) {
process.exit(1)
}
await Botpress.start({ modules })
logger.info(`Botpress is ready at http://${process.HOST}:${process.PORT}/`)
}
开发者ID:seffalabdelaziz,项目名称:botpress,代码行数:79,代码来源:bootstrap.ts
示例6:
import * as shell from 'shelljs';
import * as utils from "./script-utils";
import * as build from "./build";
import * as isWindows from "is-windows";
import chalk from 'chalk';
utils.exitIfNotRunFromRootDir();
//------------------------------------
utils.printTaskHeading('Checking your local environment');
if (isWindows()) {
const scriptShell = shell.exec('npm config get script-shell', { silent: true }).stdout.toString().trim();
if (!scriptShell.endsWith('bash.exe')) {
console.log('');
console.log(chalk.black.bgRedBright(`Warning!`) + chalk.redBright(` On Windows, we strongly recommend Git Bash as an npm script-shell.`));
console.log('');
console.log(chalk.whiteBright(`We detected your current script-shell is: ${scriptShell === 'null' ? 'cmd.exe' : scriptShell}`));
console.log(chalk.whiteBright(`You can set a script-shell by running:`));
console.log('');
console.log(chalk.whiteBright(` npm config set script-shell "c:\\Program Files\\git\\bin\\bash.exe"`));
}
}
//------------------------------------
utils.printTaskHeading('Configuring git');
shell.exec('git config core.ignorecase false && git config core.filemode false');
//------------------------------------
utils.printTaskHeading('Installing dependencies in ext-libs');
shell.exec('composer install -d ext-libs --ignore-platform-reqs');
开发者ID:OddenCreative,项目名称:versionpress,代码行数:30,代码来源:init-dev.ts
示例7:
'use strict';
import chalk from 'chalk';
export const log = {
info: console.log.bind(console, chalk.gray.bold('suman-utils info:')),
warning: console.error.bind(console, chalk.yellow('suman-utils warn:')),
error: console.error.bind(console, chalk.redBright('suman-utils error:')),
good: console.log.bind(console, chalk.cyan('suman-utils:')),
veryGood: console.log.bind(console, chalk.green('suman-utils:'))
};
export default log;
开发者ID:ORESoftware,项目名称:suman-utils,代码行数:13,代码来源:logger.ts
示例8: constructor
constructor (public description: string, public title: string, public filename: string) {
super();
this.message = `${chalk.redBright(description)}\n${chalk.yellow("Title: " + title + "\nFilename: " + filename)}`;
}
开发者ID:dotnetprofessional,项目名称:LiveDoc,代码行数:4,代码来源:ParserException.ts
示例9: log
function log(ctx: Context, start: number, len: number, err: any = null, event: string = null) {
const statusCode = err
? (err.statusCode || err.status || 500)
: (ctx.status || 404);
let length: string;
if ([204, 205, 304].includes(statusCode)) {
length = '';
} else if (len == null) {
length = '-';
} else {
length = bytes(len).toLowerCase();
}
let cache: string = '';
if (ctx.response.headers['x-cache-api']) {
cache = ' [' + ctx.response.headers['x-cache-api'].toLowerCase() + ']';
}
const ip = ctx.request.get('x-forwarded-for') || ctx.ip || '0.0.0.0';
const user = ctx.state.user ? ctx.state.user.name || ctx.state.user.username : '';
let logUserIp: string;
if (user) {
logUserIp = chalk.cyan(user) + ':' + chalk.blueBright(ip);
} else {
logUserIp = chalk.blueBright(ip);
}
const upstream = err ? chalk.redBright('*ERR* ') : event === 'close' ? chalk.yellowBright('*CLOSED* ') : '';
const logStatus = statusStyle[Math.floor(statusCode / 100) * 100] || statusStyle[100];
const logMethod = methodStyle[ctx.method] || methodStyle.GET;
const duration = Date.now() - start;
ctx.state.request.duration = duration;
ctx.state.request.size = len;
// log this
const message = `[${logUserIp}] ${upstream}${logStatus(' ' + statusCode + ' ')} ${logMethod(ctx.method + ' ' + ctx.originalUrl)} ${duration}ms - ${length}${cache}`;
const level = statusCode >= 500 ? 'error' : 'info';
const fullLog = statusCode >= 400 && statusCode !== 404;
const requestHeaders = stripAuthHeaders(ctx.request.headers);
logger.text(ctx.state, level, message);
logger.json(ctx.state, level, {
type: 'access',
message: `${ctx.method} ${ctx.originalUrl} [${ctx.response.status}]`,
level,
request: {
id: ctx.state.request.id,
ip: ctx.state.request.ip,
method: ctx.request.method,
path: ctx.request.url,
headers: fullLog ? Object.keys(requestHeaders)
.filter(header => !['accept', 'connection', 'pragma', 'cache-control', 'host', 'origin'].includes(header))
.reduce((obj: { [key: string]: string }, key: string) => { obj[key] = requestHeaders[key]; return obj; }, {}) : undefined,
body: ctx.request.get('content-type').startsWith('application/json') ? ctx.request.rawBody : undefined,
},
response: {
status: ctx.response.status,
body: fullLog && ctx.response.get('content-type').startsWith('application/json') ? (isObject(ctx.response.body) ? JSON.stringify(ctx.response.body) : ctx.response.body) : undefined,
headers: fullLog ? Object.keys(ctx.response.headers)
.filter(header => !['x-request-id', 'x-user-id', 'x-user-dirty', 'x-cache-api', 'x-response-time', 'x-token-refresh', 'vary', 'access-control-allow-origin', 'access-control-allow-credentials', 'access-control-expose-headers'].includes(header))
.reduce((obj: { [key: string]: string }, key: string) => { obj[key] = ctx.response.headers[key]; return obj; }, {}) : undefined,
duration: ctx.state.request.duration,
size: ctx.state.request.size,
cached: ctx.response.headers['x-cache-api'] ? ctx.response.headers['x-cache-api'] === 'HIT' : undefined,
},
});
}
开发者ID:freezy,项目名称:node-vpdb,代码行数:67,代码来源:logger.middleware.ts
注:本文中的chalk.redBright函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论