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


TypeScript generate.extend函數代碼示例

本文整理匯總了TypeScript中ember-cli/lib/commands/generate.extend函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript extend函數的具體用法?TypeScript extend怎麽用?TypeScript extend使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了extend函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

const GenerateCommand = EmberGenerateCommand.extend({
  name: 'generate',

  beforeRun: function(rawArgs: string[]) {
    if (!rawArgs.length) {
      return;
    }

    // map the blueprint name to allow for aliases
    rawArgs[0] = mapBlueprintName(rawArgs[0]);

    if (rawArgs[0] !== '--help' &&
      !fs.existsSync(path.join(__dirname, '..', 'blueprints', rawArgs[0]))) {
      SilentError.debugOrThrow('angular-cli/commands/generate', `Invalid blueprint: ${rawArgs[0]}`);
    }

    if (!rawArgs[1]) {
      SilentError.debugOrThrow('angular-cli/commands/generate',
        `The \`ng generate ${rawArgs[0]}\` command requires a name to be specified.`);
    }

    // Override default help to hide ember blueprints
    EmberGenerateCommand.prototype.printDetailedHelp = function() {
      const blueprintList = fs.readdirSync(path.join(__dirname, '..', 'blueprints'));
      const blueprints = blueprintList
        .filter(bp => bp.indexOf('-test') === -1)
        .filter(bp => bp !== 'ng2')
        .filter(bp => bp !== 'mobile')
        .map(bp => Blueprint.load(path.join(__dirname, '..', 'blueprints', bp)));

      let output = '';
      blueprints
        .forEach(function (bp) {
          output += bp.printBasicHelp(false) + os.EOL;
        });
      this.ui.writeLine(chalk.cyan('  Available blueprints'));
      this.ui.writeLine(output);
    };

    return EmberGenerateCommand.prototype.beforeRun.apply(this, arguments);
  }
});
開發者ID:dlizarra,項目名稱:angular-cli,代碼行數:42,代碼來源:generate.ts

示例2: function

import * as EmberGenerateCommand from 'ember-cli/lib/commands/generate';
import * as fs from 'fs';
import * as path from 'path';
import * as SilentError from 'silent-error';


const GenerateCommand = EmberGenerateCommand.extend({
  name: 'generate',

  beforeRun: function(rawArgs) {
    if (!rawArgs.length) {
      return;
    }

    if (!fs.existsSync(path.join(__dirname, '..', 'blueprints', rawArgs[0]))) {
      SilentError.debugOrThrow('angular-cli/commands/generate', `Invalid blueprint: ${rawArgs[0]}`);
    }

    return EmberGenerateCommand.prototype.beforeRun.apply(this, arguments);
  }
});


module.exports = GenerateCommand;
module.exports.overrideCore = true;
開發者ID:Sundar-Natarajan,項目名稱:angular-cli,代碼行數:25,代碼來源:generate.ts


注:本文中的ember-cli/lib/commands/generate.extend函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。