本文整理汇总了TypeScript中listr.run函数的典型用法代码示例。如果您正苦于以下问题:TypeScript run函数的具体用法?TypeScript run怎么用?TypeScript run使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: Listr
(async () => {
try {
const tasks = new Listr(sources.map(source => ({
title: `${chalk.dim('Fetching latest comic from')} ${chalk.yellow(source)}`,
task: async (context, task) => {
const [comic] = await devComic({sources: [source]});
task.title = `${chalk.yellow(source)}\t${chalk.green(comic.image)}`;
context[source] = comic.image;
}
})), {
concurrent: true,
exitOnError: false
});
const results = await tasks.run();
if (shouldPreview) {
Object.values(results).map(openImage);
}
} catch (error) {
/*
* This catch block is intentionally left empty, since the error is already
* being displayed under the Listr task.
*/
}
})();
开发者ID:arnellebalane,项目名称:devcomic,代码行数:27,代码来源:cli.ts
示例2: runTslintCli
export function runTslintCli(projects = PROJECTS) {
const log = createToolingLog('info');
log.pipe(process.stdout);
const opts = getopts(process.argv.slice(2));
if (!opts.format) {
process.argv.push('--format', 'stylish');
}
const list = new Listr(
projects
.filter(project => {
if (!opts.project) {
return true;
}
return resolve(opts.project) === project.tsConfigPath;
})
.map(project => ({
task: () =>
execa('tslint', [...process.argv.slice(2), '--project', project.tsConfigPath], {
cwd: project.directory,
env: chalk.enabled ? { FORCE_COLOR: 'true' } : {},
stdio: ['ignore', 'pipe', 'pipe'],
}).catch(error => {
throw new LintFailure(project, error);
}),
title: project.name,
})),
{
concurrent: true,
exitOnError: false,
}
);
list.run().catch((error: any) => {
process.exitCode = 1;
if (!error.errors) {
log.error('Unhandled execption!');
log.error(error);
process.exit();
}
for (const e of error.errors) {
if (e instanceof LintFailure) {
log.write('');
log.error(`${e.project.name} failed\n${e.error.stdout}`);
} else {
log.error(e);
}
}
});
}
开发者ID:Jaaess,项目名称:kibana,代码行数:55,代码来源:run_tslint_cli.ts
示例3: 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;
}
}
开发者ID:elastic,项目名称:kibana,代码行数:49,代码来源:extract_default_translations.ts
示例4: execInProjects
export function execInProjects(
log: ToolingLog,
projects: Project[],
cmd: string,
getArgs: (project: Project) => string[]
) {
const list = new Listr(
projects.map(project => ({
task: () =>
execa(cmd, getArgs(project), {
cwd: project.directory,
env: chalk.enabled ? { FORCE_COLOR: 'true' } : {},
stdio: ['ignore', 'pipe', 'pipe'],
}).catch(error => {
throw new ProjectFailure(project, error);
}),
title: project.name,
})),
{
concurrent: true,
exitOnError: false,
}
);
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);
}
}
});
}
开发者ID:elastic,项目名称:kibana,代码行数:45,代码来源:exec_in_projects.ts
示例5: async
async ({
flags: {
'ignore-incompatible': ignoreIncompatible,
'ignore-missing': ignoreMissing,
'ignore-unused': ignoreUnused,
'include-config': includeConfig,
fix = false,
path,
},
log,
}) => {
if (
fix &&
(ignoreIncompatible !== undefined ||
ignoreUnused !== undefined ||
ignoreMissing !== undefined)
) {
throw createFailError(
`${chalk.white.bgRed(
' I18N ERROR '
)} none of the --ignore-incompatible, --ignore-unused or --ignore-missing is allowed when --fix is set.`
);
}
if (typeof path === 'boolean' || typeof includeConfig === 'boolean') {
throw createFailError(
`${chalk.white.bgRed(' I18N ERROR ')} --path and --include-config require a value`
);
}
if (typeof fix !== 'boolean') {
throw createFailError(`${chalk.white.bgRed(' I18N ERROR ')} --fix can't have a value`);
}
const config = await mergeConfigs(includeConfig);
const defaultMessages = await extractDefaultMessages({ path, config });
if (config.translations.length === 0) {
return;
}
const list = new Listr(
config.translations.map(translationsPath => ({
task: async () => {
// If `--fix` is set we should try apply all possible fixes and override translations file.
await integrateLocaleFiles(defaultMessages, {
sourceFileName: translationsPath,
targetFileName: fix ? translationsPath : undefined,
dryRun: !fix,
ignoreIncompatible: fix || !!ignoreIncompatible,
ignoreUnused: fix || !!ignoreUnused,
ignoreMissing: fix || !!ignoreMissing,
config,
log,
});
},
title: `Compatibility check with ${translationsPath}`,
})),
{
concurrent: true,
exitOnError: false,
}
);
try {
await list.run();
} catch (error) {
process.exitCode = 1;
if (!error.errors) {
log.error('Unhandled exception!');
log.error(error);
process.exit();
}
for (const e of error.errors) {
log.error(e);
}
}
},
开发者ID:elastic,项目名称:kibana,代码行数:80,代码来源:run_i18n_check.ts
注:本文中的listr.run函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论