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


TypeScript core.basename函数代码示例

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


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

示例1: importPath

export function importPath(from: Path, to: Path): string {
  const relativePath = relative(dirname(from), dirname(to));

  if (relativePath.startsWith('.')) {
    return relativePath;
  }

  if (!relativePath) {
    return generateCurrentDirImport(basename(to));
  }

  return generateCurrentDirImport(join(relativePath, basename(to)));
}
开发者ID:kevinheader,项目名称:nebular,代码行数:13,代码来源:path.ts

示例2: return

  return (host: Tree, context: SchematicContext) => {
    const clientProject = getClientProject(host, options);
    if (clientProject.projectType !== 'application') {
      throw new SchematicsException(`Universal requires a project type of "application".`);
    }
    const clientArchitect = getClientArchitect(host, options);
    const outDir = getTsConfigOutDir(host, clientArchitect);
    const tsConfigExtends = basename(clientArchitect.build.options.tsConfig);

    if (!options.skipInstall) {
      context.addTask(new NodePackageInstallTask());
    }

    const templateSource = apply(url('./files'), [
      template({
        ...strings,
        ...options as object,
        stripTsExtension: (s: string) => { return s.replace(/\.ts$/, ''); },
        outDir,
        tsConfigExtends,
      }),
      move(clientProject.root),
    ]);

    return chain([
      mergeWith(templateSource),
      addDependencies(),
      updateConfigFile(options),
      wrapBootstrapCall(options),
      addServerTransition(options),
    ])(host, context);
  };
开发者ID:iwe7,项目名称:devkit,代码行数:32,代码来源:index.ts

示例3: resolve

 buildProcess.once('close', (code: number) => {
   if (code === 0) {
     resolve();
   } else {
     reject(new Error(`${basename(binary)} failed with code ${code}.`));
   }
 });
开发者ID:StephenFluin,项目名称:angular,代码行数:7,代码来源:bazel.ts

示例4: async

  return async (host: Tree, context: SchematicContext) => {
    const workspace = await getWorkspace(host);

    const clientProject = workspace.projects.get(options.clientProject);
    if (!clientProject || clientProject.extensions.projectType !== 'application') {
      throw new SchematicsException(`Universal requires a project type of "application".`);
    }

    const clientBuildTarget = clientProject.targets.get('build');
    if (!clientBuildTarget) {
      throw targetBuildNotFoundError();
    }
    const clientBuildOptions =
      (clientBuildTarget.options || {}) as unknown as BrowserBuilderOptions;

    const outDir = getTsConfigOutDir(host, clientBuildOptions.tsConfig);

    const clientTsConfig = normalize(clientBuildOptions.tsConfig);
    const tsConfigExtends = basename(clientTsConfig);
    // this is needed because prior to version 8, tsconfig might have been in 'src'
    // and we don't want to break the 'ng add @nguniversal/express-engine schematics'
    const rootInSrc = clientProject.root === '' && clientTsConfig.includes('src/');
    const tsConfigDirectory = join(normalize(clientProject.root), rootInSrc ? 'src' : '');

    if (!options.skipInstall) {
      context.addTask(new NodePackageInstallTask());
    }

    const templateSource = apply(url('./files/src'), [
      applyTemplates({
        ...strings,
        ...options as object,
        stripTsExtension: (s: string) => s.replace(/\.ts$/, ''),
      }),
      move(join(normalize(clientProject.root), 'src')),
    ]);

    const rootSource = apply(url('./files/root'), [
      applyTemplates({
        ...strings,
        ...options as object,
        stripTsExtension: (s: string) => s.replace(/\.ts$/, ''),
        outDir,
        tsConfigExtends,
        rootInSrc,
      }),
      move(tsConfigDirectory),
    ]);

    return chain([
      mergeWith(templateSource),
      mergeWith(rootSource),
      addDependencies(),
      updateConfigFile(options, tsConfigDirectory),
      wrapBootstrapCall(clientBuildOptions.main),
      addServerTransition(options, clientBuildOptions.main, clientProject.root),
    ]);
  };
开发者ID:angular,项目名称:angular-cli,代码行数:58,代码来源:index.ts

示例5: parseName

export function parseName(path: string, name: string): Location {
  const nameWithoutPath = basename(name as Path);
  const namePath = dirname((path + '/' + name) as Path);

  return {
    name: nameWithoutPath,
    path: normalize('/' + namePath),
  };
}
开发者ID:AlexChar,项目名称:platform,代码行数:9,代码来源:parse-name.ts

示例6: parsePath

function parsePath(path: string) {
  const pathNormalized = normalize(path) as Path;
  const filename = extname(pathNormalized) ? basename(pathNormalized) : '';
  const directory = filename ? dirname(pathNormalized) : pathNormalized;
  return {
    path: pathNormalized,
    filename,
    directory,
  };
}
开发者ID:AlexChar,项目名称:platform,代码行数:10,代码来源:find-module.ts

示例7: optionsFromDir

function optionsFromDir(moduleDir: DirEntry): ModuleOptions {
  const moduleName = basename(moduleDir.path);
  const routingModuleFileName = generateRoutingModuleFileName(moduleName);

  return {
    path: moduleDir.path,
    featureModuleFileName: generateFeatureModuleFileName(moduleName),
    featureModuleClassName: generateFeatureModuleClassName(moduleName),
    routingModuleFileName,
    routingModuleClassName: generateRoutingModuleClassName(moduleName),
    routingModuleImportPath: generateCurrentDirImport(routingModuleFileName),
  };
}
开发者ID:kevinheader,项目名称:nebular,代码行数:13,代码来源:generate-missing-modules.ts

示例8: shouldCreateModule

function shouldCreateModule(tree: Tree, filePath: Path): boolean {
  const dir = tree.getDir(normalize(dirname(filePath)));
  const fileName = basename(filePath);
  const isModuleExist = isFeatureModule(fileName)
    ? hasFeatureModuleInDir(dir)
    : hasRoutingModuleInDir(dir);

  if (isModuleExist) {
    return false;
  }

  return isFeatureModule(fileName) || hasComponentsInDir(dir);
}
开发者ID:kevinheader,项目名称:nebular,代码行数:13,代码来源:generate-missing-modules.ts

示例9: normalize

    .map(assetPattern => {
      // Normalize string asset patterns to objects.
      if (typeof assetPattern === 'string') {
        const assetPath = normalize(assetPattern);
        const resolvedAssetPath = resolve(root, assetPath);

        // Check if the string asset is within sourceRoot.
        if (!resolvedAssetPath.startsWith(resolvedSourceRoot)) {
          throw new MissingAssetSourceRootException(assetPattern);
        }

        let glob: string, input: Path, output: Path;
        let isDirectory = false;

        try {
          isDirectory = host.isDirectory(resolvedAssetPath);
        } catch {
          isDirectory = true;
        }

        if (isDirectory) {
          // Folders get a recursive star glob.
          glob = '**/*';
          // Input directory is their original path.
          input = assetPath;
        } else {
          // Files are their own glob.
          glob = basename(assetPath);
          // Input directory is their original dirname.
          input = dirname(assetPath);
        }

        // Output directory for both is the relative path from source root to input.
        output = relative(resolvedSourceRoot, resolve(root, input));

        // Return the asset pattern in object format.
        return { glob, input, output };
      } else {
        // It's already an AssetPatternObject, no need to convert.
        return assetPattern;
      }
    });
开发者ID:DevIntent,项目名称:angular-cli,代码行数:42,代码来源:normalize-asset-patterns.ts

示例10: map

          map(isDirectory => {
            let glob: string, input: Path, output: Path;
            if (isDirectory) {
              // Folders get a recursive star glob.
              glob = '**/*';
              // Input directory is their original path.
              input = assetPath;
            } else {
              // Files are their own glob.
              glob = basename(assetPath);
              // Input directory is their original dirname.
              input = dirname(assetPath);
            }

            // Output directory for both is the relative path from source root to input.
            output = relative(resolvedSourceRoot, resolve(root, input));

            // Return the asset pattern in object format.
            return { glob, input, output };
          }),
开发者ID:baconwaffles,项目名称:angular-cli,代码行数:20,代码来源:normalize-asset-patterns.ts


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