本文整理汇总了TypeScript中gulp-util.colors.gray方法的典型用法代码示例。如果您正苦于以下问题:TypeScript colors.gray方法的具体用法?TypeScript colors.gray怎么用?TypeScript colors.gray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gulp-util.colors
的用法示例。
在下文中一共展示了colors.gray方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
error: (error: TypeScriptError, typescript: typeof ts) => {
console.error('[' + gutil.colors.gray('gulp-typescript') + '] '
+ gutil.colors.bgRed(error.diagnostic.code + '')
+ ' ' + gutil.colors.red(flattenDiagnosticsVerbose(error.diagnostic.messageText))
);
if (error.tsFile) {
console.error('> ' + gutil.colors.gray('file: ') + (fullFilename ? error.fullFilename : error.relativeFilename) + gutil.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.error('> ' + gutil.colors.gray('[' + lineIndex + '] ')
+ line.substring(0, errorStart)
+ gutil.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
);
}
}
},
示例2: flattenDiagnosticsVerbose
error: (error: TypeScriptError) => {
if (error.tsFile) {
console.error('[' + gutil.colors.gray('gulp-typescript') + '] ' + gutil.colors.red(error.fullFilename + '(' + error.startPosition.line + ',' + error.startPosition.character + '): ') + 'error TS' + error.diagnostic.code + ' ' + flattenDiagnosticsVerbose(error.diagnostic.messageText));
} else {
console.error(error.message);
}
},
示例3: modifyFile
export = (done: any) => {
// Note: dirty hack until we're able to set config easier
modifyFile(join(Config.TMP_DIR, 'tsconfig.json'), (content: string) => {
const parsed = JSON.parse(content);
const path = join(
Config.PROJECT_ROOT,
Config.TOOLS_DIR,
'manual_typings',
'project'
);
parsed.files = parsed.files || [];
parsed.files = parsed.files.concat(
readdirSync(path)
.filter(f => f.endsWith('d.ts'))
.map(f => join(path, f))
);
parsed.files = parsed.files.filter(
(f: string, i: number) => parsed.files.indexOf(f) === i
);
parsed.files.push(join(Config.BOOTSTRAP_DIR, 'main.ts'));
return JSON.stringify(parsed, null, 2);
});
const args = argv as any;
// If a translation, tell the compiler
if (args.lang) {
let i18nFilePath = `${Config.LOCALE_DEST}/messages.${args.lang}.xlf`;
let isExists = existsSync(i18nFilePath);
if (isExists) {
args['i18nFile'] = i18nFilePath;
args['locale'] = args.lang;
args['i18nFormat'] = 'xlf';
} else {
util.log(util.colors.gray('Translation file is not found'), util.colors.yellow(i18nFilePath));
util.log(util.colors.gray(`Use 'npm run i18n' command to create your translation file`));
}
}
const cliOptions = new NgcCliOptions(args);
main(Config.TMP_DIR, cliOptions, codegen)
.then(done)
.catch(e => {
console.error(e.stack);
console.error('Compilation failed');
process.exit(1);
});
};
示例4: existsSync
.forEach((key: string) => {
if (key === 'lang') {
const lang: string = namedArgs[key] as string;
const i18nFilePath = `${Config.LOCALE_DEST}/messages.${lang}.xlf`;
const isExists = existsSync(i18nFilePath);
if (isExists) {
args.push('--i18nFile', i18nFilePath);
args.push('--locale', lang);
args.push('--i18nFormat', 'xlf');
} else {
util.log(util.colors.gray('Translation file is not found'), util.colors.yellow(i18nFilePath));
util.log(util.colors.gray(`Use 'npm run i18n' command to create your translation file`));
}
} else {
args.push('--' + key, namedArgs[key]);
}
});