當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。