當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。