当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript strings.camelize方法代码示例

本文整理汇总了TypeScript中@angular-devkit/core.strings.camelize方法的典型用法代码示例。如果您正苦于以下问题:TypeScript strings.camelize方法的具体用法?TypeScript strings.camelize怎么用?TypeScript strings.camelize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@angular-devkit/core.strings的用法示例。


在下文中一共展示了strings.camelize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: return

  return (tree: Tree, context: SchematicContext) => {
    if (!options.name) {
      throw new SchematicsException('name option is required.');
    }

    let collectionPath: Path | undefined;
    try {
      const packageJsonContent = tree.read('/package.json');
      if (packageJsonContent) {
        const packageJson = JSON.parse(packageJsonContent.toString('utf-8'));
        if ('schematics' in packageJson) {
          const p = normalize(packageJson['schematics']);
          if (tree.exists(p)) {
            collectionPath = p;
          }
        }
      }
    } catch (_) {
    }

    let source = apply(url('./schematic-files'), [
        applyTemplates({
          ...options as object,
          coreVersion,
          schematicsVersion,
          dot: '.',
          camelize: strings.camelize,
          dasherize: strings.dasherize,
        }),
      ]);

    // Simply create a new schematic project.
    if (!collectionPath) {
      collectionPath = normalize('/' + options.name + '/src/collection.json');
      source = apply(url('./project-files'), [
        applyTemplates({
          ...options as object,
          coreVersion,
          schematicsVersion,
          dot: '.',
          camelize: strings.camelize,
          dasherize: strings.dasherize,
        }),
        mergeWith(source),
        move(options.name),
      ]);

      context.addTask(new NodePackageInstallTask(options.name));
    }

    return chain([
      mergeWith(source),
      addSchematicToCollectionJson(collectionPath, strings.dasherize(options.name), {
        description: 'A blank schematic.',
        factory: './' + strings.dasherize(options.name) + '/index#' +
          strings.camelize(options.name),
      }),
    ]);
  };
开发者ID:angular,项目名称:angular-cli,代码行数:59,代码来源:factory.ts

示例2: buildSelector

function buildSelector(options: DirectiveOptions, projectPrefix: string) {
  let selector = options.name;
  if (options.prefix) {
    selector = `${options.prefix}-${selector}`;
  } else if (options.prefix === undefined && projectPrefix) {
    selector = `${projectPrefix}-${selector}`;
  }

  return strings.camelize(selector);
}
开发者ID:angular,项目名称:angular-cli,代码行数:10,代码来源:index.ts

示例3: _getOptionFromName

function _getOptionFromName(name: string, options: Option[]): Option | undefined {
  const cName = strings.camelize(name);

  for (const option of options) {
    if (option.name == name || option.name == cName) {
      return option;
    }

    if (option.aliases.some(x => x == name || x == cName)) {
      return option;
    }
  }

  return undefined;
}
开发者ID:baconwaffles,项目名称:angular-cli,代码行数:15,代码来源:parser.ts

示例4: _assignOption

function _assignOption(
  arg: string,
  nextArg: string | undefined,
  { options, parsedOptions, leftovers, ignored, errors, warnings }: {
    options: Option[],
    parsedOptions: Arguments,
    positionals: string[],
    leftovers: string[],
    ignored: string[],
    errors: string[],
    warnings: string[],
  },
) {
  const from = arg.startsWith('--') ? 2 : 1;
  let consumedNextArg = false;
  let key = arg.substr(from);
  let option: Option | null = null;
  let value: string | undefined = '';
  const i = arg.indexOf('=');

  // If flag is --no-abc AND there's no equal sign.
  if (i == -1) {
    if (key.startsWith('no')) {
      // Only use this key if the option matching the rest is a boolean.
      const from = key.startsWith('no-') ? 3 : 2;
      const maybeOption = _getOptionFromName(strings.camelize(key.substr(from)), options);
      if (maybeOption && maybeOption.type == 'boolean') {
        value = 'false';
        option = maybeOption;
      }
    }

    if (option === null) {
      // Set it to true if it's a boolean and the next argument doesn't match true/false.
      const maybeOption = _getOptionFromName(key, options);
      if (maybeOption) {
        value = nextArg;
        let shouldShift = true;

        if (value && value.startsWith('-')) {
          // Verify if not having a value results in a correct parse, if so don't shift.
          if (_coerce(undefined, maybeOption) !== undefined) {
            shouldShift = false;
          }
        }

        // Only absorb it if it leads to a better value.
        if (shouldShift && _coerce(value, maybeOption) !== undefined) {
          consumedNextArg = true;
        } else {
          value = '';
        }
        option = maybeOption;
      }
    }
  } else {
    key = arg.substring(0, i);
    option = _getOptionFromName(_removeLeadingDashes(key), options) || null;
    if (option) {
      value = arg.substring(i + 1);
    }
  }

  if (option === null) {
    if (nextArg && !nextArg.startsWith('-')) {
      leftovers.push(arg, nextArg);
      consumedNextArg = true;
    } else {
      leftovers.push(arg);
    }
  } else {
    const v = _coerce(value, option, parsedOptions[option.name]);
    if (v !== undefined) {
      if (parsedOptions[option.name] !== v) {
        if (parsedOptions[option.name] !== undefined) {
          warnings.push(
            `Option ${JSON.stringify(option.name)} was already specified with value `
            + `${JSON.stringify(parsedOptions[option.name])}. The new value ${JSON.stringify(v)} `
            + `will override it.`,
          );
        }

        parsedOptions[option.name] = v;

        if (option.deprecated !== undefined && option.deprecated !== false) {
          warnings.push(`Option ${JSON.stringify(option.name)} is deprecated${
            typeof option.deprecated == 'string' ? ': ' + option.deprecated : '.'}`);
        }
      }
    } else {
      let error = `Argument ${key} could not be parsed using value ${JSON.stringify(value)}.`;
      if (option.enum) {
        error += ` Valid values are: ${option.enum.map(x => JSON.stringify(x)).join(', ')}.`;
      } else {
        error += `Valid type(s) is: ${(option.types || [option.type]).join(', ')}`;
      }

      errors.push(error);
      ignored.push(arg);
    }
//.........这里部分代码省略.........
开发者ID:DevIntent,项目名称:angular-cli,代码行数:101,代码来源:parser.ts

示例5:

 .map(b => coreStrings.camelize(b))
开发者ID:rexebin,项目名称:angular-cli,代码行数:1,代码来源:command-runner.ts


注:本文中的@angular-devkit/core.strings.camelize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。