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


TypeScript yeoman-environment.getGeneratorsMeta函数代码示例

本文整理汇总了TypeScript中yeoman-environment.getGeneratorsMeta函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getGeneratorsMeta函数的具体用法?TypeScript getGeneratorsMeta怎么用?TypeScript getGeneratorsMeta使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getGeneratorsMeta函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: runGenerator

export async function runGenerator(
    generatorName: string, options: {[name: string]: any} = {}): Promise<void> {
  const templateName = options['templateName'] || generatorName;

  const env: YeomanEnvironment =
      await (options['env'] || createYeomanEnvironment());

  logger.info(`Running template ${templateName}...`);
  logger.debug(`Running generator ${generatorName}...`);
  const generators = env.getGeneratorsMeta();
  const generator = generators[generatorName];

  if (!generator) {
    logger.error(`Template ${templateName} not found`);
    throw new Error(`Template ${templateName} not found`);
  }

  return new Promise<void>((resolve, reject) => {
    env.run(generatorName, {}, (error: any) => {
      if (error) {
        reject(error);
        return;
      }
      resolve();
    });
  });
}
开发者ID:abdonrd,项目名称:polymer-cli,代码行数:27,代码来源:init.ts

示例2: createSelectPrompt

/**
 * Create the prompt used for selecting which template to run. Generate
 * the list of available generators by filtering relevent ones out from
 * the environment list.
 */
function createSelectPrompt(env: YeomanEnvironment) {
  const generators = env.getGeneratorsMeta();
  const allGeneratorNames = Object.keys(generators).filter((k) => {
    return k.startsWith('polymer-init') && k !== 'polymer-init:app';
  });
  const choices = allGeneratorNames.map((generatorName: string) => {
    const generator = generators[generatorName];
    return getGeneratorDescription(generator, generatorName);
  });

  return {
    message: 'Which starter template would you like to use?',
    choices: choices,
  };
}
开发者ID:abdonrd,项目名称:polymer-cli,代码行数:20,代码来源:init.ts

示例3: createSelectPrompt

/**
 * Create the prompt used for selecting which template to run. Generate
 * the list of available generators by filtering relevent ones out from
 * the environment list.
 */
function createSelectPrompt(env: YeomanEnvironment): InquirerQuestion {
  const generators = env.getGeneratorsMeta();
  const allGeneratorNames = Object.keys(generators).filter((k) => {
    return k.startsWith('polymer-init') && k !== 'polymer-init:app';
  });
  const choices = allGeneratorNames.map((generatorName: string) => {
    const generator = generators[generatorName];
    return getGeneratorDescription(generator, generatorName);
  });

  // Some windows emulators (mingw) don't handle arrows correctly
  // https://github.com/SBoudrias/Inquirer.js/issues/266
  // Fall back to rawlist and use number input
  // Credit to
  // https://gist.github.com/geddski/c42feb364f3c671d22b6390d82b8af8f
  const isMinGW = checkIsMinGW();

  return {
    type: isMinGW ? 'rawlist' : 'list',
    name: 'generatorName',
    message: 'Which starter template would you like to use?',
    choices: choices,
  };
}
开发者ID:fwielstra,项目名称:polymer-cli,代码行数:29,代码来源:init.ts


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