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


TypeScript ember-cli-string-utils.dasherize函数代码示例

本文整理汇总了TypeScript中ember-cli-string-utils.dasherize函数的典型用法代码示例。如果您正苦于以下问题:TypeScript dasherize函数的具体用法?TypeScript dasherize怎么用?TypeScript dasherize使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: function

  locals: function(options: any) {
    this.styleExt = options.style === 'stylus' ? 'styl' : options.style;
    this.version = require(path.resolve(__dirname, '../../package.json')).version;
    // set this.tests to opposite of skipTest options,
    // meaning if tests are being skipped then the default.spec.BLUEPRINT will be false
    this.tests = options.skipTests ? false : true;

    // Split/join with / not path.sep as reference to typings require forward slashes.
    const relativeRootPath = options.sourceDir.split('/').map(() => '..').join('/');
    const fullAppName = (stringUtils.dasherize(options.entity.name) as string)
      .replace(/-(.)/g, (_, l) => ' ' + l.toUpperCase())
      .replace(/^./, (l) => l.toUpperCase());

    return {
      htmlComponentName: stringUtils.dasherize(options.entity.name),
      jsComponentName: stringUtils.classify(options.entity.name),
      fullAppName: fullAppName,
      version: this.version,
      sourceDir: options.sourceDir,
      prefix: options.prefix,
      styleExt: this.styleExt,
      relativeRootPath: relativeRootPath,
      routing: options.routing,
      inlineStyle: options.inlineStyle,
      inlineTemplate: options.inlineTemplate,
      ng4: options.ng4,
      tests: this.tests
    };
  },
开发者ID:Percyman,项目名称:angular-cli,代码行数:29,代码来源:index.ts

示例2: function

  normalizeEntityName: function (entityName: string) {
    const appConfig = getAppFromConfig(this.options.app);
    const dynamicPathOptions: DynamicPathOptions = {
      project: this.project,
      entityName,
      appConfig,
      dryRun: this.options.dryRun
    };
    const parsedPath = dynamicPathParser(dynamicPathOptions);

    this.dynamicPath = parsedPath;

    const defaultPrefix = (appConfig && appConfig.prefix) || '';

    let prefix = (this.options.prefix === 'false' || this.options.prefix === '')
      ? '' : (this.options.prefix || defaultPrefix);
    prefix = prefix && `${prefix}-`;

    this.selector = stringUtils.dasherize(prefix + parsedPath.name);

    if (this.selector.indexOf('-') === -1) {
      this._writeStatusToUI(chalk.yellow, 'WARNING', 'selectors should contain a dash');
    }

    return parsedPath.name;
  },
开发者ID:PatrionDigital,项目名称:patriondigital.github.io,代码行数:26,代码来源:index.ts

示例3: function

  afterInstall: function (options: any) {
    const appConfig = getAppFromConfig(this.options.app);
    if (options.prefix && appConfig.prefix && appConfig.prefix !== options.prefix) {
      console.log(chalk.yellow(oneLine`You are using different prefix from app,
       you might get lint errors. Please update "tslint.json" accordingly.`));
    }

    const returns: Array<any> = [];
    const className = stringUtils.classify(`${options.entity.name}Component`);
    const fileName = stringUtils.dasherize(`${options.entity.name}.component`);
    const componentDir = path.relative(path.dirname(this.pathToModule), this.generatePath);
    const normalizeRelativeDir = componentDir.startsWith('.') ? componentDir : `./${componentDir}`;
    const importPath = componentDir ? `${normalizeRelativeDir}/${fileName}` : `./${fileName}`;

    if (!options.skipImport) {
      if (options.dryRun) {
        this._writeStatusToUI(chalk.yellow,
          'update',
          path.relative(this.project.root, this.pathToModule));
        return;
      }

      let preChange: any;
      try {
         preChange = fs.readFileSync(this.pathToModule, 'utf8');
      } catch (err) {
        if (err.code === 'EISDIR') {
          throw 'Module specified should be a file, not a directory';
        } else {
          throw err;
        }
      }

      returns.push(
        astUtils.addDeclarationToModule(this.pathToModule, className, importPath)
          .then((change: any) => change.apply(NodeHost))
          .then((result: any) => {
            if (options.export) {
              return astUtils.addExportToModule(this.pathToModule, className, importPath)
                .then((change: any) => change.apply(NodeHost));
            }
            return result;
          })
          .then(() => {
            const postChange = fs.readFileSync(this.pathToModule, 'utf8');
            let moduleStatus = 'update';

            if (postChange === preChange) {
              moduleStatus = 'identical';
            }

            this._writeStatusToUI(chalk.yellow,
              moduleStatus,
              path.relative(this.project.root, this.pathToModule));
            this.addModifiedFile(this.pathToModule);
          }));
    }

    return Promise.all(returns);
  }
开发者ID:AlexGavrilov939,项目名称:GitHunt-Angular,代码行数:60,代码来源:index.ts

示例4: function

  afterInstall: function(options: any) {
    if (options.dryRun) {
      return;
    }

    const returns: Array<any> = [];
    const className = stringUtils.classify(`${options.entity.name}Directive`);
    const fileName = stringUtils.dasherize(`${options.entity.name}.directive`);
    const fullGeneratePath = path.join(this.project.root, this.generatePath);
    const moduleDir = path.parse(this.pathToModule).dir;
    const relativeDir = path.relative(moduleDir, fullGeneratePath);
    const importPath = relativeDir ? `./${relativeDir}/${fileName}` : `./${fileName}`;

    if (!options.skipImport) {
      returns.push(
        astUtils.addDeclarationToModule(this.pathToModule, className, importPath)
          .then((change: any) => change.apply(NodeHost))
          .then((result: any) => {
            if (options.export) {
              return astUtils.addExportToModule(this.pathToModule, className, importPath)
                .then((change: any) => change.apply(NodeHost));
            }
            return result;
          }));
      this._writeStatusToUI(chalk.yellow,
                            'update',
                            path.relative(this.project.root, this.pathToModule));
    }

    return Promise.all(returns);
  }
开发者ID:cntxCL,项目名称:paceApp,代码行数:31,代码来源:index.ts

示例5: function

  run: function (commandOptions: any, rawArgs: string[]) {
    if (rawArgs[0] === 'module' && !rawArgs[1]) {
      throw 'The `ng generate module` command requires a name to be specified.';
    }

    const entityName = rawArgs[1];
    commandOptions.name = stringUtils.dasherize(entityName.split(separatorRegEx).pop());

    const appConfig = getAppFromConfig(commandOptions.app);
    const dynamicPathOptions: DynamicPathOptions = {
      project: this.project,
      entityName: entityName,
      appConfig: appConfig,
      dryRun: commandOptions.dryRun
    };
    const parsedPath = dynamicPathParser(dynamicPathOptions);
    const root = appConfig.root + path.sep;
    commandOptions.sourceDir = appConfig.root;
    commandOptions.appRoot = parsedPath.appRoot.startsWith(root)
      ? parsedPath.appRoot.substr(root.length)
      : parsedPath.appRoot;
    commandOptions.path = parsedPath.dir.replace(separatorRegEx, '/');
    if (parsedPath.dir.startsWith(root)) {
      commandOptions.path = commandOptions.path.substr(root.length);
    }

    const cwd = this.project.root;
    const schematicName = rawArgs[0];

    if (['component', 'c', 'directive', 'd'].indexOf(schematicName) !== -1) {
      if (commandOptions.prefix === undefined) {
        commandOptions.prefix = appConfig.prefix;
      }

      if (schematicName === 'component' || schematicName === 'c') {
        if (commandOptions.styleext === undefined) {
          commandOptions.styleext = CliConfig.getValue('defaults.styleExt');
        }
      }
    }

    const SchematicRunTask = require('../tasks/schematic-run').default;
    const schematicRunTask = new SchematicRunTask({
      ui: this.ui,
      project: this.project
    });
    const collectionName = this.getCollectionName(rawArgs);

    if (collectionName === '@schematics/angular' && schematicName === 'interface' && rawArgs[2]) {
      commandOptions.type = rawArgs[2];
    }

    return schematicRunTask.run({
        taskOptions: commandOptions,
        workingDir: cwd,
        collectionName,
        schematicName
      });
  },
开发者ID:dzonatan,项目名称:angular-cli,代码行数:59,代码来源:generate.ts

示例6: function

  locals: function (options: any) {
    this.fileName = stringUtils.dasherize(options.entity.name);

    return {
      dynamicPath: this.dynamicPath.dir,
      flat: options.flat,
      fileName: this.fileName
    };
  },
开发者ID:dahang,项目名称:angular-cli,代码行数:9,代码来源:index.ts

示例7: function

  afterInstall: function (options: any) {
    const returns: Array<any> = [];
    const className = stringUtils.classify(`${options.entity.name}Component`);
    const fileName = stringUtils.dasherize(`${options.entity.name}.component`);
    const componentDir = path.relative(path.dirname(this.pathToModule), this.generatePath);
    const importPath = componentDir ? `./${componentDir}/${fileName}` : `./${fileName}`;

    if (!options.skipImport) {
      if (options.dryRun) {
        this._writeStatusToUI(chalk.yellow,
          'update',
          path.relative(this.project.root, this.pathToModule));
        return;
      }

      let preChange: any;
      try {
         preChange = fs.readFileSync(this.pathToModule, 'utf8');
      } catch (err) {
        if (err.code === 'EISDIR') {
          throw 'Module specified should be a file, not a directory';
        } else {
          throw err;
        }
      }

      returns.push(
        astUtils.addDeclarationToModule(this.pathToModule, className, importPath)
          .then((change: any) => change.apply(NodeHost))
          .then((result: any) => {
            if (options.export) {
              return astUtils.addExportToModule(this.pathToModule, className, importPath)
                .then((change: any) => change.apply(NodeHost));
            }
            return result;
          })
          .then(() => {
            const postChange = fs.readFileSync(this.pathToModule, 'utf8');
            let moduleStatus = 'update';

            if (postChange === preChange) {
              moduleStatus = 'identical';
            }

            this._writeStatusToUI(chalk.yellow,
              moduleStatus,
              path.relative(this.project.root, this.pathToModule));
          }));
    }

    return Promise.all(returns);
  }
开发者ID:numerized,项目名称:angular-inport,代码行数:52,代码来源:index.ts

示例8: function

  run: function (commandOptions: any, rawArgs: string[]) {
    if (rawArgs[0] === 'module' && !rawArgs[1]) {
      throw 'The `ng generate module` command requires a name to be specified.';
    }

    const entityName = rawArgs[1];
    commandOptions.name = stringUtils.dasherize(entityName.split(separatorRegEx).pop());

    const appConfig = getAppFromConfig(commandOptions.app);
    const dynamicPathOptions: DynamicPathOptions = {
      project: this.project,
      entityName: entityName,
      appConfig: appConfig,
      dryRun: commandOptions.dryRun
    };
    const parsedPath = dynamicPathParser(dynamicPathOptions);
    commandOptions.sourceDir = appConfig.root;
    commandOptions.path = parsedPath.dir
      .replace(appConfig.root + path.sep, '')
      .replace(separatorRegEx, '/');

    const cwd = this.project.root;
    const schematicName = rawArgs[0];

    const SchematicRunTask = require('../tasks/schematic-run').default;
    const schematicRunTask = new SchematicRunTask({
      ui: this.ui,
      project: this.project
    });
    const collectionName = this.getCollectionName(rawArgs);

    if (collectionName === '@schematics/angular' && schematicName === 'interface' && rawArgs[2]) {
      commandOptions.type = rawArgs[2];
    }

    return schematicRunTask.run({
        taskOptions: commandOptions,
        workingDir: cwd,
        collectionName,
        schematicName
      });
  },
开发者ID:alexspring123,项目名称:angular-cli,代码行数:42,代码来源:generate.ts


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