本文整理汇总了TypeScript中chalk.white类的典型用法代码示例。如果您正苦于以下问题:TypeScript white类的具体用法?TypeScript white怎么用?TypeScript white使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了white类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: async
async ({
flags: {
path,
'output-dir': outputDir,
'output-format': outputFormat,
'include-config': includeConfig,
},
}) => {
if (!outputDir || typeof outputDir !== 'string') {
throw createFailError(
`${chalk.white.bgRed(' I18N ERROR ')} --output-dir option should be specified.`
);
}
if (typeof path === 'boolean' || typeof includeConfig === 'boolean') {
throw createFailError(
`${chalk.white.bgRed(' I18N ERROR ')} --path and --include-config require a value`
);
}
const config = await mergeConfigs(includeConfig);
const defaultMessages = await extractDefaultMessages({ path, config });
// Messages shouldn't be written to a file if output is not supplied.
if (!outputDir || !defaultMessages.size) {
return;
}
const sortedMessages = [...defaultMessages].sort(([key1], [key2]) => key1.localeCompare(key2));
await writeFileAsync(
resolve(outputDir, 'en.json'),
outputFormat === 'json5' ? serializeToJson5(sortedMessages) : serializeToJson(sortedMessages)
);
},
示例2:
this.project.documents.entries.forEach((document: Document) => {
console.log(
' ',
chalk.gray('Format:'),
chalk.white.bold(document.format)
)
console.log(' ', chalk.gray('Path:'), chalk.white.bold(document.path))
console.log('')
})
示例3: log
export function log( type: 'title' | 'success' | 'error' | 'step' | 'substep' | 'default' = 'default', message: string = '' ): void {
switch( type ) {
case 'title':
console.log( chalk.white.bold.underline( message ) );
break;
case 'success':
console.log( chalk.green.bold( message ) );
break;
case 'error':
console.log( chalk.red.bold( message ) );
break;
case 'step':
console.log( chalk.white.bold( ` ${ message }` ) );
break;
case 'substep':
console.log( chalk.gray( ` ${ arrowSymbol } ${ message }` ) );
break;
default:
console.log( message );
}
}
示例4: onRootShutdown
function onRootShutdown(reason?: any) {
if (reason !== undefined) {
// There is a chance that logger wasn't configured properly and error that
// that forced root to shut down could go unnoticed. To prevent this we always
// mirror such fatal errors in standard output with `console.error`.
// tslint:disable no-console
console.error(`\n${chalk.white.bgRed(' FATAL ')} ${reason}\n`);
}
process.exit(reason === undefined ? 0 : (reason as any).processExitCode || 1);
}
示例5: getCallbackId
const sendRequest = <DataT extends object | undefined>(
method: string, path: string, data?: DataT, authenticating: boolean = false
) => {
// Pre-checks
if (!authenticating && !socket().isConnected()) {
logger.warn(`Attempting to send request on a non-authenticated socket: ${path}`);
return Promise.reject('Not authorized');
}
if (!socket().nativeSocket) {
logger.warn(`Attempting to send request without a socket: ${path}`);
return Promise.reject('No socket');
}
const callbackId = getCallbackId();
// Reporting
invariant(path, 'Attempting socket request without a path');
const ignored = eventIgnored(path, ignoredRequestPaths);
if (!ignored) {
logger.verbose(
chalk.white.bold(callbackId.toString()),
method,
path,
data ? filterPassword(data) : '(no data)'
);
}
// Callback
const resolver = Promise.pending();
callbacks[callbackId] = {
time: new Date().getTime(),
resolver,
ignored,
};
// Actual request
const request = {
path,
method,
data,
callback_id: callbackId,
} as APIInternal.OutgoingRequest;
socket().nativeSocket!.send(JSON.stringify(request));
return resolver.promise;
};
示例6: extractDefaultMessages
export async function extractDefaultMessages({
path,
config,
}: {
path?: string | string[];
config: I18nConfig;
}) {
const filteredPaths = filterConfigPaths(Array.isArray(path) ? path : [path || './'], config);
if (filteredPaths.length === 0) {
throw createFailError(
`${chalk.white.bgRed(
' I18N ERROR '
)} None of input paths is covered by the mappings in .i18nrc.json.`
);
}
const reporter = new ErrorReporter();
const list = new Listr(
filteredPaths.map(filteredPath => ({
task: async (messages: Map<string, unknown>) => {
const initialErrorsNumber = reporter.errors.length;
// Return result if no new errors were reported for this path.
const result = await extractMessagesFromPathToMap(filteredPath, messages, config, reporter);
if (reporter.errors.length === initialErrorsNumber) {
return result;
}
// Throw an empty error to make Listr mark the task as failed without any message.
throw new Error('');
},
title: filteredPath,
})),
{
exitOnError: false,
}
);
try {
return await list.run(new Map());
} catch (error) {
if (error.name === 'ListrError' && reporter.errors.length) {
throw createFailError(reporter.errors.join('\n\n'));
}
throw error;
}
}
示例7: banner
/**
* Standard output block to help call out these interstitial messages amidst
* large test suite outputs.
*/
function banner(text: string): string {
return chalk.white.bgRed(
`*************************\n\n${text}\n\n*************************`);
}
示例8: echoStatus
public echoStatus(prefix: string, statusText: string) {
console.log(chalk.white.bold(prefix), chalk.green(statusText));
}
示例9: async
async ({
flags: {
'dry-run': dryRun = false,
'ignore-incompatible': ignoreIncompatible = false,
'ignore-missing': ignoreMissing = false,
'ignore-unused': ignoreUnused = false,
'include-config': includeConfig,
path,
source,
target,
},
log,
}) => {
if (!source || typeof source === 'boolean') {
throw createFailError(`${chalk.white.bgRed(' I18N ERROR ')} --source option isn't provided.`);
}
if (Array.isArray(source)) {
throw createFailError(
`${chalk.white.bgRed(' I18N ERROR ')} --source should be specified only once.`
);
}
if (typeof target === 'boolean' || Array.isArray(target)) {
throw createFailError(
`${chalk.white.bgRed(
' I18N ERROR '
)} --target should be specified only once and must have a value.`
);
}
if (typeof path === 'boolean' || typeof includeConfig === 'boolean') {
throw createFailError(
`${chalk.white.bgRed(' I18N ERROR ')} --path and --include-config require a value`
);
}
if (
typeof ignoreIncompatible !== 'boolean' ||
typeof ignoreUnused !== 'boolean' ||
typeof ignoreMissing !== 'boolean' ||
typeof dryRun !== 'boolean'
) {
throw createFailError(
`${chalk.white.bgRed(
' I18N ERROR '
)} --ignore-incompatible, --ignore-unused, --ignore-missing, and --dry-run can't have values`
);
}
const config = await mergeConfigs(includeConfig);
const defaultMessages = await extractDefaultMessages({ path, config });
await integrateLocaleFiles(defaultMessages, {
sourceFileName: source,
targetFileName: target,
dryRun,
ignoreIncompatible,
ignoreUnused,
ignoreMissing,
config,
log,
});
},