當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript listr.run函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。