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


TypeScript silent-error.debugOrThrow函數代碼示例

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


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

示例1: function

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

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

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

    if (!isHelp && !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 () {
      this.ui.writeLine(chalk.cyan('  Available blueprints'));
      this.ui.writeLine(blueprints.map(bp => bp.printBasicHelp(false)).join(os.EOL));
    };

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

示例2: function

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

    const isHelp = ['--help', '-h'].includes(rawArgs[0]);
    if (isHelp) {
      return;
    }

    this.blueprints = loadBlueprints();

    const name = rawArgs[0];
    const blueprint = this.blueprints.find((bp: any) => bp.name === name
      || (bp.aliases && bp.aliases.includes(name)));

    if (!blueprint) {
      SilentError.debugOrThrow('@angular/cli/commands/generate',
        `Invalid blueprint: ${name}`);
    }

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

    if (/^\d/.test(rawArgs[1])) {
      SilentError.debugOrThrow('@angular/cli/commands/generate',
          `The \`ng generate ${name} ${rawArgs[1]}\` file name cannot begin with a digit.`);
    }

    rawArgs[0] = blueprint.name;
    this.registerOptions(blueprint);
  },
開發者ID:RoPP,項目名稱:angular-cli,代碼行數:34,代碼來源:generate.ts

示例3: function

  beforeRun: function (rawArgs: string[]) {
    const isHelp = ['--help', '-h'].includes(rawArgs[0]);
    if (isHelp) {
      return;
    }

    const schematicName = CliConfig.getValue('defaults.schematics.newApp');

    if (/^\d/.test(rawArgs[1])) {
      SilentError.debugOrThrow('@angular/cli/commands/generate',
        `The \`ng new ${rawArgs[0]}\` file name cannot begin with a digit.`);
    }

    const SchematicGetOptionsTask = require('../tasks/schematic-get-options').default;

    const getOptionsTask = new SchematicGetOptionsTask({
      ui: this.ui,
      project: this.project
    });

    return getOptionsTask.run({
      schematicName,
      collectionName: this.getCollectionName(rawArgs)
    })
      .then((availableOptions: SchematicAvailableOptions) => {
        this.registerOptions({
          availableOptions: availableOptions
        });
      });
  },
開發者ID:RicardoVaranda,項目名稱:angular-cli,代碼行數:30,代碼來源:new.ts

示例4: function

  beforeRun: function(rawArgs) {
    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]}`);
    }
    
    // Override default help to hide ember blueprints
    EmberGenerateCommand.prototype.printDetailedHelp = function (options) {
      var blueprintList = fs.readdirSync(path.join(__dirname, '..', 'blueprints'));
      var blueprints = blueprintList
        .filter(bp => bp.indexOf('-test') === -1)
        .filter(bp => bp !== 'ng2')
        .map(bp => Blueprint.load(path.join(__dirname, '..', 'blueprints', bp)));
      
      var output = '';
      blueprints
        .forEach(function (bp) {
          output += bp.printBasicHelp(false) + EOL;
        });
      this.ui.writeLine(chalk.cyan('  Available blueprints'));
      this.ui.writeLine(output);
    };
    
    return EmberGenerateCommand.prototype.beforeRun.apply(this, arguments);
  }
開發者ID:2blessed2bstressedbythedevilsmess,項目名稱:angular-cli,代碼行數:32,代碼來源:generate.ts

示例5: function

  beforeRun: function(rawArgs: string[]) {

    const isHelp = ['--help', '-h'].includes(rawArgs[0]);
    if (isHelp) {
      return;
    }

    const [collectionName, schematicName] = this.getCollectionName(rawArgs);
    if (!schematicName) {
      return Promise.reject(new SilentError(oneLine`
          The "ng generate" command requires a
          schematic name to be specified.
          For more details, use "ng help".
      `));
    }

    if (/^\d/.test(rawArgs[1])) {
      SilentError.debugOrThrow('@angular/cli/commands/generate',
        `The \`ng generate ${schematicName} ${rawArgs[1]}\` file name cannot begin with a digit.`);
    }

    const SchematicGetOptionsTask = require('../tasks/schematic-get-options').default;

    const getOptionsTask = new SchematicGetOptionsTask({
      ui: this.ui,
      project: this.project
    });

    return getOptionsTask.run({
        schematicName,
        collectionName
      })
      .then((availableOptions: SchematicAvailableOptions[]) => {
        let anonymousOptions: string[] = [];

        if (availableOptions) {
          const nameOption = availableOptions.filter(opt => opt.name === 'name')[0];
          if (nameOption) {
            anonymousOptions = [...anonymousOptions, '<name>'];
          }
        } else {
          anonymousOptions = [...anonymousOptions, '<name>'];
        }

        if (collectionName === '@schematics/angular' && schematicName === 'interface') {
          anonymousOptions = [...anonymousOptions, '<type>'];
        }

        this.registerOptions({
          anonymousOptions: anonymousOptions,
          availableOptions: availableOptions || []
        });
      });
  },
開發者ID:Serdji,項目名稱:angular-cli,代碼行數:54,代碼來源:generate.ts

示例6: function

  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);
  }
開發者ID:Sundar-Natarajan,項目名稱:angular-cli,代碼行數:11,代碼來源:generate.ts


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