当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ToolingLog.error方法代码示例

本文整理汇总了TypeScript中@kbn/dev-utils.ToolingLog.error方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ToolingLog.error方法的具体用法?TypeScript ToolingLog.error怎么用?TypeScript ToolingLog.error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@kbn/dev-utils.ToolingLog的用法示例。


在下文中一共展示了ToolingLog.error方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
      );
    }
  }
}
开发者ID:JinlongHe,项目名称:kibana,代码行数:31,代码来源:lint_files.ts

示例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);
      }
    }
  });
开发者ID:austec-automation,项目名称:kibana,代码行数:18,代码来源:exec_in_projects.ts

示例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);
      }
    }
  });
开发者ID:elastic,项目名称:kibana,代码行数:20,代码来源:exec_in_projects.ts

示例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);
    }
  }
}
开发者ID:njd5475,项目名称:kibana,代码行数:36,代码来源:run.ts

示例5:

 const logDeprecation = (error: string | Error) => log.error(error);
开发者ID:elastic,项目名称:kibana,代码行数:1,代码来源:read_config_file.ts

示例6: runTypeCheckCli

export function runTypeCheckCli() {
  const extraFlags: string[] = [];
  const opts = getopts(process.argv.slice(2), {
    boolean: ['skip-lib-check', 'help'],
    default: {
      project: undefined,
    },
    unknown(name) {
      extraFlags.push(name);
      return false;
    },
  });

  const log = new ToolingLog({
    level: 'info',
    writeTo: process.stdout,
  });

  if (extraFlags.length) {
    for (const flag of extraFlags) {
      log.error(`Unknown flag: ${flag}`);
    }

    process.exitCode = 1;
    opts.help = true;
  }

  if (opts.help) {
    process.stdout.write(
      dedent(chalk`
        {dim usage:} node scripts/type_check [...options]

        Run the TypeScript compiler without emitting files so that it can check
        types during development.

        Examples:

          {dim # check types in all projects}
          {dim $} node scripts/type_check

          {dim # check types in a single project}
          {dim $} node scripts/type_check --project packages/kbn-pm/tsconfig.json

        Options:

          --project [path]    {dim Path to a tsconfig.json file determines the project to check}
          --skip-lib-check    {dim Skip type checking of all declaration files (*.d.ts)}
          --help              {dim Show this message}
      `)
    );
    process.stdout.write('\n');
    process.exit();
  }

  const tscArgs = ['--noEmit', '--pretty', ...(opts['skip-lib-check'] ? ['--skipLibCheck'] : [])];
  const projects = filterProjectsByFlag(opts.project);

  if (!projects.length) {
    log.error(`Unable to find project at ${opts.project}`);
    process.exit(1);
  }

  execInProjects(log, projects, 'tsc', project => ['--project', project.tsConfigPath, ...tscArgs]);
}
开发者ID:austec-automation,项目名称:kibana,代码行数:64,代码来源:run_type_check_cli.ts

示例7: run

async function run(folder: string): Promise<boolean> {
  const log = new ToolingLog({
    level: 'info',
    writeTo: process.stdout,
  });

  const extraFlags: string[] = [];
  const opts = getopts(process.argv.slice(2), {
    boolean: ['accept', 'docs', 'help'],
    default: {
      project: undefined,
    },
    unknown(name) {
      extraFlags.push(name);
      return false;
    },
  });

  if (extraFlags.length > 0) {
    for (const flag of extraFlags) {
      log.error(`Unknown flag: ${flag}`);
    }

    opts.help = true;
  }

  if (opts.help) {
    process.stdout.write(
      dedent(chalk`
        {dim usage:} node scripts/check_core_api_changes [...options]

        Checks for any changes to the Kibana Core API

        Examples:

          {dim # Checks for any changes to the Kibana Core API}
          {dim $} node scripts/check_core_api_changes

          {dim # Checks for any changes to the Kibana Core API and updates the documentation}
          {dim $} node scripts/check_core_api_changes --docs

          {dim # Checks for and automatically accepts and updates documentation for any changes to the Kibana Core API}
          {dim $} node scripts/check_core_api_changes --accept

        Options:
          --accept    {dim Accepts all changes by updating the API Review files and documentation}
          --docs      {dim Updates the Core API documentation}
          --help      {dim Show this message}
      `)
    );
    process.stdout.write('\n');
    return !(extraFlags.length > 0);
  }

  log.info(`Core ${folder} API: checking for changes in API signature...`);

  try {
    await runBuildTypes();
  } catch (e) {
    log.error(e);
    return false;
  }

  const { apiReportChanged, succeeded } = runApiExtractor(log, folder, opts.accept);

  // If we're not accepting changes and there's a failure, exit.
  if (!opts.accept && !succeeded) {
    return false;
  }

  // Attempt to generate docs even if api-extractor didn't succeed
  if ((opts.accept && apiReportChanged) || opts.docs) {
    try {
      await renameExtractedApiPackageName(folder);
      await runApiDocumenter(folder);
    } catch (e) {
      log.error(e);
      return false;
    }
    log.info(`Core ${folder} API: updated documentation ✔`);
  }

  // If any errors or warnings occured, exit with an error
  return succeeded;
}
开发者ID:horacimacias,项目名称:kibana,代码行数:85,代码来源:run_check_core_api_changes.ts


注:本文中的@kbn/dev-utils.ToolingLog.error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。