本文整理汇总了TypeScript中@kbn/dev-utils.ToolingLog.write方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ToolingLog.write方法的具体用法?TypeScript ToolingLog.write怎么用?TypeScript ToolingLog.write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@kbn/dev-utils.ToolingLog
的用法示例。
在下文中一共展示了ToolingLog.write方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: lintFiles
export async function lintFiles(log: ToolingLog, files: File[]) {
for (const [project, filesInProject] of groupFilesByProject(files)) {
const exitCode = await run(
{
exclude: [],
files: filesInProject.map(f => f.getAbsolutePath()),
fix: false,
format: 'stylish',
project: project.tsConfigPath,
},
{
log(m: string) {
log.write(m);
},
error(m: string) {
log.error(m);
},
}
);
if (exitCode > 0) {
throw createFailError(`[tslint] failure`, 1);
} else {
log.success(
'[tslint/%s] %d files linted successfully',
project.name,
filesInProject.length
);
}
}
}
示例2:
list.run().catch((error: any) => {
process.exitCode = 1;
if (!error.errors) {
log.error('Unhandled exception!');
log.error(error);
process.exit();
}
for (const e of error.errors) {
if (e instanceof ProjectFailure) {
log.write('');
log.error(`${e.project.name} failed\n${e.error.stdout}`);
} else {
log.error(e);
}
}
});
示例3:
list.run().catch((error: any) => {
process.exitCode = 1;
if (!error.errors) {
log.error('Unhandled exception!');
log.error(error);
process.exit();
}
for (const e of error.errors) {
if (e instanceof ProjectFailure) {
log.write('');
// stdout contains errors from tsc
// stderr conatins tsc crash report
log.error(`${e.project.name} failed\n${e.error.stdout || e.error.stderr}`);
} else {
log.error(e);
}
}
});
示例4: run
export async function run(fn: RunFn, options: Options = {}) {
const flags = getFlags(process.argv.slice(2), options);
const allowUnexpected = options.flags ? options.flags.allowUnexpected : false;
if (flags.help) {
process.stderr.write(getHelp(options));
process.exit(1);
}
const log = new ToolingLog({
level: pickLevelFromFlags(flags),
writeTo: process.stdout,
});
try {
if (!allowUnexpected && flags.unexpected.length) {
throw createFlagError(`Unknown flag(s) "${flags.unexpected.join('", "')}"`);
}
await fn({ log, flags });
} catch (error) {
if (isFailError(error)) {
log.error(error.message);
if (error.showHelp) {
log.write(getHelp(options));
}
process.exit(error.exitCode);
} else {
log.error('UNHANDLED ERROR');
log.error(error);
process.exit(1);
}
}
}