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


TypeScript cli-framework.validate函數代碼示例

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


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

示例1: preRun

  async preRun(inputs: CommandLineInputs, options: CommandLineOptions, runinfo: CommandInstanceInfo): Promise<void> {
    await this.preRunChecks(runinfo);

    inputs[0] = !inputs[0] ? 'ls' : inputs[0];
    inputs[0] = (inputs[0] === 'rm') ? 'remove' : inputs[0];
    inputs[0] = (inputs[0] === 'list') ? 'ls' : inputs[0];

    validate(inputs[0], 'action', [contains(['add', 'remove', 'ls', 'save'], {})]);

    // If the action is list then lets just end here.
    if (['ls', 'save'].includes(inputs[0])) {
      await this.runCordova(['plugin', inputs[0]], {});
      throw new FatalException('', 0);
    }

    if (!inputs[1]) {
      const plugin = await this.env.prompt({
        message: `What plugin would you like to ${inputs[0]}:`,
        type: 'input',
        name: 'plugin',
      });

      inputs[1] = plugin;
    }

    validate(inputs[1], 'plugin', [validators.required]);
  }
開發者ID:driftyco,項目名稱:ionic-cli,代碼行數:27,代碼來源:plugin.ts

示例2: preRun

  async preRun(inputs: CommandLineInputs, options: CommandLineOptions, runinfo: CommandInstanceInfo): Promise<void> {
    await this.preRunChecks(runinfo);

    if (options['r'] || options['noresources']) {
      options['resources'] = false;
    }

    inputs[0] = !inputs[0] ? 'ls' : inputs[0];
    inputs[0] = (inputs[0] === 'rm') ? 'remove' : inputs[0];
    inputs[0] = (inputs[0] === 'list') ? 'ls' : inputs[0];

    validate(inputs[0], 'action', [contains(['add', 'remove', 'update', 'ls', 'check', 'save'], {})]);

    // If the action is list, check, or save, then just end here.
    if (['ls', 'check', 'save'].includes(inputs[0])) {
      await this.runCordova(['platform', inputs[0]], {});
      throw new FatalException('', 0);
    }

    if (!inputs[1]) {
      const platform = await this.env.prompt({
        type: 'input',
        name: 'platform',
        message: `What platform would you like to ${inputs[0]} (${['android', 'ios'].map(v => input(v)).join(', ')}):`,
      });

      inputs[1] = platform.trim();
    }

    validate(inputs[1], 'platform', [validators.required]);
  }
開發者ID:driftyco,項目名稱:ionic-cli,代碼行數:31,代碼來源:platform.ts

示例3: run

  async run(inputs: CommandLineInputs, options: CommandLineOptions): Promise<void> {
    const { formatAilmentMessage } = await import('../../lib/doctor');

    const [ id ] = inputs;

    if (id) {
      const registry = await this.getRegistry();
      const ailmentIds = registry.ailments.map(a => a.id);
      validate(id, 'id', [contains(ailmentIds, {})]);
      const ailment = registry.get(id);

      if (!ailment) {
        throw new FatalException(`Issue not found by ID: ${input(id)}`);
      }

      const detected = await ailment.detected();

      if (!detected) {
        this.env.log.ok(`${input(ailment.id)} does not need fixing as it was not detected.`);
        return;
      }

      if (!isTreatableAilment(ailment)) {
        this.env.log.warn(await formatAilmentMessage(ailment));

        throw new FatalException(
          `Issue cannot be fixed automatically: ${input(ailment.id)}\n` +
          `Unfortunately the CLI can't automatically fix the specified issue at this time. However, please see the steps above for manually fixing the issue.`
        );
      }

      if (this.env.config.get(`doctor.issues.${ailment.id}.ignored` as any)) {
        const confirm = await this.env.prompt({
          type: 'confirm',
          name: 'confirm',
          message: `${input(ailment.id)} is ignored, are you sure you want to continue?`,
        });

        if (!confirm) {
          return;
        }

        this.env.config.unset(`doctor.issues.${ailment.id}.ignored` as any);
      }

      try {
        await this.treatAilment(ailment);
      } catch (e) {
        this.handleError(e);
      }
    } else {
      const ailments = await this.detectTreatableAilments();
      await this.treatAilments(ailments);
    }
  }
開發者ID:driftyco,項目名稱:ionic-cli,代碼行數:55,代碼來源:treat.ts

示例4: preRun

  async preRun(inputs: CommandLineInputs, options: CommandLineOptions): Promise<void> {
    await this.checkForOpenSSH();

    this.env.session.getUserToken();

    if (!options['annotation']) {
      options['annotation'] = this.env.config.get('user.email');
    }

    validate(String(options['type']), 'type', [contains(SSH_KEY_TYPES, { caseSensitive: false })]);
  }
開發者ID:driftyco,項目名稱:ionic-cli,代碼行數:11,代碼來源:generate.ts

示例5: run

  async run(inputs: CommandLineInputs, options: CommandLineOptions): Promise<void> {
    const [ id ] = inputs;

    if (id) {
      const registry = await this.getRegistry();
      const ailmentIds = registry.ailments.map(a => a.id);
      validate(id, 'id', [contains(ailmentIds, {})]);
      const ailment = registry.get(id);

      if (!ailment) {
        throw new FatalException(`Issue not found by ID: ${input(id)}`);
      }

      await this.checkAilment(ailment);
    } else {
      const ailments = await this.detectAilments();
      await this.checkAilments(ailments);
    }
  }
開發者ID:driftyco,項目名稱:ionic-cli,代碼行數:19,代碼來源:check.ts


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