本文整理汇总了TypeScript中ansi-colors.red函数的典型用法代码示例。如果您正苦于以下问题:TypeScript red函数的具体用法?TypeScript red怎么用?TypeScript red使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了red函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: log
export = (done: any) => {
log(colors.yellow(`
Warning!
Please use ${colors.green('npm run build.prod')}
Instead of ${colors.red('npm run build.prod.aot')} or ${colors.red('npm run build.prod.aot')}
They will be deleted soon!`));
done();
};
示例2: defaultFinishHandler
function defaultFinishHandler(results: CompilationResult) {
let hasError = false;
const showErrorCount = (count: number, type: string) => {
if (count === 0) return;
console.log('TypeScript:', colors.magenta(count.toString()), (type !== '' ? type + ' ' : '') + (count === 1 ? 'error' : 'errors'));
hasError = true;
};
showErrorCount(results.transpileErrors, '');
showErrorCount(results.optionsErrors, 'options');
showErrorCount(results.syntaxErrors, 'syntax');
showErrorCount(results.globalErrors, 'global');
showErrorCount(results.semanticErrors, 'semantic');
showErrorCount(results.declarationErrors, 'declaration');
showErrorCount(results.emitErrors, 'emit');
if (!results.noEmit) {
if (results.emitSkipped) {
console.log('TypeScript: emit', colors.red('failed'));
} else if (hasError) {
console.log('TypeScript: emit', colors.cyan('succeeded'), '(with errors)');
}
}
}
示例3:
error: (error: TypeScriptError, typescript: typeof ts) => {
console.log('[' + colors.gray('gulp-typescript') + '] '
+ colors.bgRed(error.diagnostic.code + '')
+ ' ' + colors.red(typescript.flattenDiagnosticMessageText(error.diagnostic.messageText, '\n'))
);
if (error.tsFile) {
console.log('> ' + colors.gray('file: ') + (fullFilename ? error.fullFilename : error.relativeFilename) + colors.gray(':'));
const lines = error.tsFile.text.split(/(?:\r\n|\r|\n)/);
const logLine = (lineIndex: number, errorStart: number, errorEnd?: number) => {
const line = lines[lineIndex];
if (errorEnd === undefined) errorEnd = line.length;
console.log('> ' + colors.gray('[' + lineIndex + '] ')
+ line.substring(0, errorStart)
+ colors.red(line.substring(errorStart, errorEnd))
+ line.substring(errorEnd)
);
}
for (let i = error.startPosition.line; i <= error.endPosition.line; i++) {
logLine(i,
i === error.startPosition.line ? error.startPosition.character - 1 : 0,
i === error.endPosition.line ? error.endPosition.character - 1 : undefined
);
}
}
},
示例4: validateTasks
.forEach(([tasks, file]: [string, string]) => {
const invalid = validateTasks(tasks);
if (invalid.length) {
const errorMessage = getInvalidTaskErrorMessage(invalid, file);
log(colors.red(errorMessage));
process.exit(1);
}
});
示例5: function
}, function () {
if (log) {
if (entry.totalCount === 1) {
fancyLog(`Stats for '${ansiColors.grey(entry.name)}': ${Math.round(entry.totalSize / 1204)}KB`);
} else {
const count = entry.totalCount < 100
? ansiColors.green(entry.totalCount.toString())
: ansiColors.red(entry.totalCount.toString());
fancyLog(`Stats for '${ansiColors.grey(entry.name)}': ${count} files, ${Math.round(entry.totalSize / 1204)}KB`);
}
}
this.emit('end');
});
示例6: toString
toString(pretty?: boolean): string {
if (!pretty) {
if (this.totalCount === 1) {
return `${this.name}: ${this.totalSize} bytes`;
} else {
return `${this.name}: ${this.totalCount} files with ${this.totalSize} bytes`;
}
} else {
if (this.totalCount === 1) {
return `Stats for '${ansiColors.grey(this.name)}': ${Math.round(this.totalSize / 1204)}KB`;
} else {
const count = this.totalCount < 100
? ansiColors.green(this.totalCount.toString())
: ansiColors.red(this.totalCount.toString());
return `Stats for '${ansiColors.grey(this.name)}': ${count} files, ${Math.round(this.totalSize / 1204)}KB`;
}
}
}
示例7:
import * as colors from 'ansi-colors';
let s: string;
s = colors.bgblack("hello");
s = colors.bgblue("hello");
s = colors.bgcyan("hello");
s = colors.bggreen("hello");
s = colors.bgmagenta("hello");
s = colors.bgred("hello");
s = colors.bgwhite("hello");
s = colors.bgyellow("hello");
s = colors.black("hello");
s = colors.blue("hello");
s = colors.bold("hello");
s = colors.cyan("hello");
s = colors.dim("hello");
s = colors.gray("hello");
s = colors.green("hello");
s = colors.grey("hello");
s = colors.hidden("hello");
s = colors.inverse("hello");
s = colors.italic("hello");
s = colors.magenta("hello");
s = colors.red("hello");
s = colors.reset("hello");
s = colors.strikethrough("hello");
s = colors.underline("hello");
s = colors.white("hello");
s = colors.yellow("hello");
示例8: fancyLog
errors.map(err => {
if (!seen.has(err)) {
seen.add(err);
fancyLog(`${ansiColors.red('Error')}: ${err}`);
}
});