当前位置: 首页>>代码示例>>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;未经允许,请勿转载。