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


TypeScript core.strings類代碼示例

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


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

示例1: update

    compiler.hooks.compilation.tap('ArchitectPlugin', compilation => {
      const hooks = hookSafelist;
      if (reset) {
        reset = false;
        modulesCount = modulesDone = hooksDone = numberOfHooks = 0;
      }
      // Need to add hooks for each compilation.
      numberOfHooks += hooks.length;

      // Pre-emptively tell the user.
      context.reportRunning();
      update('Preparing...');

      compilation.hooks.buildModule.tap('ArchitectPlugin', buildModule);
      compilation.hooks.failedModule.tap('ArchitectPlugin', failedModule);
      compilation.hooks.succeedModule.tap('ArchitectPlugin', succeedModule);

      for (const name of hooks) {
        // Transforms `camelCase` into `Camel case`. decamelize() transforms it into `camel_case`
        // and then we replace the `_` with spaces.
        const title = strings.capitalize(strings.decamelize(name).replace(/_/g, ' '));

        compilation.hooks[name].intercept({
          call: () => {
            hooksDone++;
            update(title);
          },
        });
      }
    });
開發者ID:angular,項目名稱:angular-cli,代碼行數:30,代碼來源:architect.ts

示例2: 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

示例3: getRelativePath

function getRelativePath(path: string, schema: CommonSchema) {
  const importPath =
    `/${schema.path}/` +
    (schema.flat ? '' : strings.dasherize(schema.name) + '/') +
    strings.dasherize(schema.name) +
    '.component';
  return buildRelativePath(path, importPath);
}
開發者ID:wexz,項目名稱:delon,代碼行數:8,代碼來源:alain.ts

示例4: return

  return (host: Tree) => {
    if (options.skipImport || !options.module) {
      return host;
    }

    const modulePath = options.module;
    const text = host.read(modulePath);
    if (text === null) {
      throw new SchematicsException(`File ${modulePath} does not exist.`);
    }
    const sourceText = text.toString('utf-8');
    const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);

    const componentPath = `/${options.path}/`
                          + (options.flat ? '' : strings.dasherize(options.name) + '/')
                          + strings.dasherize(options.name)
                          + '.component';
    const relativePath = buildRelativePath(modulePath, componentPath);
    const classifiedName = strings.classify(`${options.name}Component`);
    const declarationChanges = addDeclarationToModule(source,
                                                      modulePath,
                                                      classifiedName,
                                                      relativePath);

    const declarationRecorder = host.beginUpdate(modulePath);
    for (const change of declarationChanges) {
      if (change instanceof InsertChange) {
        declarationRecorder.insertLeft(change.pos, change.toAdd);
      }
    }
    host.commitUpdate(declarationRecorder);

    if (options.export) {
      // Need to refresh the AST because we overwrote the file in the host.
      const text = host.read(modulePath);
      if (text === null) {
        throw new SchematicsException(`File ${modulePath} does not exist.`);
      }
      const sourceText = text.toString('utf-8');
      const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);

      const exportRecorder = host.beginUpdate(modulePath);
      const exportChanges = addExportToModule(source, modulePath,
                                              strings.classify(`${options.name}Component`),
                                              relativePath);

      for (const change of exportChanges) {
        if (change instanceof InsertChange) {
          exportRecorder.insertLeft(change.pos, change.toAdd);
        }
      }
      host.commitUpdate(exportRecorder);
    }


    return host;
  };
開發者ID:iwe7,項目名稱:devkit,代碼行數:57,代碼來源:index.ts

示例5:

    const allCommands = Object.keys(commandMap).sort((a, b) => {
      if (!(a in commandsDistance)) {
        commandsDistance[a] = strings.levenshtein(a, name);
      }
      if (!(b in commandsDistance)) {
        commandsDistance[b] = strings.levenshtein(b, name);
      }

      return commandsDistance[a] - commandsDistance[b];
    });
開發者ID:DevIntent,項目名稱:angular-cli,代碼行數:10,代碼來源:command-runner.ts

示例6: return

  return (host: Tree) => {
    if (options.skipImport || !options.module) {
      return host;
    }

    const modulePath = options.module;
    const text = host.read(modulePath);
    if (text === null) {
      throw new SchematicsException(`File ${modulePath} does not exist.`);
    }
    const sourceText = text.toString('utf-8');
    const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);

    const pipePath = `/${options.path}/`
                     + (options.flat ? '' : strings.dasherize(options.name) + '/')
                     + strings.dasherize(options.name)
                     + '.pipe';
    const relativePath = buildRelativePath(modulePath, pipePath);
    const changes = addDeclarationToModule(source, modulePath,
                                           strings.classify(`${options.name}Pipe`),
                                           relativePath);
    const recorder = host.beginUpdate(modulePath);
    for (const change of changes) {
      if (change instanceof InsertChange) {
        recorder.insertLeft(change.pos, change.toAdd);
      }
    }
    host.commitUpdate(recorder);

    if (options.export) {
      const text = host.read(modulePath);
      if (text === null) {
        throw new SchematicsException(`File ${modulePath} does not exist.`);
      }
      const sourceText = text.toString('utf-8');
      const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);

      const exportRecorder = host.beginUpdate(modulePath);
      const exportChanges = addExportToModule(source, modulePath,
                                              strings.classify(`${options.name}Pipe`),
                                              relativePath);

      for (const change of exportChanges) {
        if (change instanceof InsertChange) {
          exportRecorder.insertLeft(change.pos, change.toAdd);
        }
      }
      host.commitUpdate(exportRecorder);
    }

    return host;
  };
開發者ID:angular,項目名稱:angular-cli,代碼行數:52,代碼來源:index.ts

示例7: buildComponentName

function buildComponentName(schema: CommonSchema, projectPrefix: string) {
  const ret: string[] = [schema.module];
  if (schema.target && schema.target.length > 0) ret.push(schema.target);
  ret.push(schema.name);
  ret.push(`Component`);
  return strings.classify(ret.join('-'));
}
開發者ID:wexz,項目名稱:delon,代碼行數:7,代碼來源:alain.ts

示例8: findModuleFromOptions

export function findModuleFromOptions(host: Tree, options: ModuleOptions): Path | undefined {
  if (options.hasOwnProperty('skipImport') && options.skipImport) {
    return undefined;
  }

  if (!options.module) {
    const pathToCheck = (options.sourceDir || '') + '/' + (options.path || '')
                      + (options.flat ? '' : '/' + strings.dasherize(options.name));

    return normalize(findModule(host, pathToCheck));
  } else {
    const modulePath = normalize(
      '/' + options.sourceDir + '/' + (options.appRoot || options.path) + '/' + options.module);
    const moduleBaseName = normalize(modulePath).split('/').pop();

    if (host.exists(modulePath)) {
      return normalize(modulePath);
    } else if (host.exists(modulePath + '.ts')) {
      return normalize(modulePath + '.ts');
    } else if (host.exists(modulePath + '.module.ts')) {
      return normalize(modulePath + '.module.ts');
    } else if (host.exists(modulePath + '/' + moduleBaseName + '.module.ts')) {
      return normalize(modulePath + '/' + moduleBaseName + '.module.ts');
    } else {
      throw new Error('Specified module does not exist');
    }
  }
}
開發者ID:beqom,項目名稱:clarity,代碼行數:28,代碼來源:find-module.ts

示例9: buildSelector

function buildSelector(options: any) {
  let selector = strings.dasherize(options.name);
  if (options.prefix) {
    selector = `${options.prefix}-${selector}`;
  }

  return selector;
}
開發者ID:kevinheader,項目名稱:nebular,代碼行數:8,代碼來源:index.ts

示例10: 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


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