• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript canonical-path.resolve函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: findR3SymbolsPath

export function findR3SymbolsPath(directory: string, filename: string): string|null {
  const r3SymbolsFilePath = resolve(directory, filename);
  if (existsSync(r3SymbolsFilePath)) {
    return r3SymbolsFilePath;
  }

  const subDirectories =
      readdirSync(directory)
          // Not interested in hidden files
          .filter(p => !p.startsWith('.'))
          // Ignore node_modules
          .filter(p => p !== 'node_modules')
          // Only interested in directories (and only those that are not symlinks)
          .filter(p => {
            const stat = lstatSync(resolve(directory, p));
            return stat.isDirectory() && !stat.isSymbolicLink();
          });

  for (const subDirectory of subDirectories) {
    const r3SymbolsFilePath = findR3SymbolsPath(resolve(directory, subDirectory, ), filename);
    if (r3SymbolsFilePath) {
      return r3SymbolsFilePath;
    }
  }

  return null;
}
开发者ID:cyrilletuzi,项目名称:angular,代码行数:27,代码来源:bundle_program.ts


示例2: renderSourceAndMap

  /**
   * Merge the input and output source-maps, replacing the source-map comment in the output file
   * with an appropriate source-map comment pointing to the merged source-map.
   */
  protected renderSourceAndMap(
      sourceFile: ts.SourceFile, input: SourceMapInfo, output: MagicString): FileInfo[] {
    const outputPath = resolve(this.targetPath, relative(this.sourcePath, sourceFile.fileName));
    const outputMapPath = `${outputPath}.map`;
    const outputMap = output.generateMap({
      source: sourceFile.fileName,
      includeContent: true,
      // hires: true // TODO: This results in accurate but huge sourcemaps. Instead we should fix
      // the merge algorithm.
    });

    // we must set this after generation as magic string does "manipulation" on the path
    outputMap.file = outputPath;

    const mergedMap =
        mergeSourceMaps(input.map && input.map.toObject(), JSON.parse(outputMap.toString()));

    const result: FileInfo[] = [];
    if (input.isInline) {
      result.push({path: outputPath, contents: `${output.toString()}\n${mergedMap.toComment()}`});
    } else {
      result.push({
        path: outputPath,
        contents: `${output.toString()}\n${generateMapFileComment(outputMapPath)}`
      });
      result.push({path: outputMapPath, contents: mergedMap.toJSON()});
    }
    return result;
  }
开发者ID:felixfbecker,项目名称:angular,代码行数:33,代码来源:renderer.ts


示例3: renderFile

  renderFile(
      sourceFile: ts.SourceFile, decorationAnalysis: DecorationAnalysis|undefined,
      switchMarkerAnalysis: SwitchMarkerAnalysis|undefined, targetPath: string): FileInfo[] {
    const renderedFiles =
        super.renderFile(sourceFile, decorationAnalysis, switchMarkerAnalysis, targetPath);

    // Transform the `.d.ts` files.
    // TODO(gkalpak): What about `.d.ts` source maps? (See
    // https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-9.html#new---declarationmap.)
    if (decorationAnalysis) {
      // Create a `DtsFileTransformer` for the source file and record the generated fields, which
      // will allow the corresponding `.d.ts` file to be transformed later.
      const dtsTransformer = new DtsFileTransformer(this.rewriteCoreImportsTo, IMPORT_PREFIX);
      decorationAnalysis.analyzedClasses.forEach(
          analyzedClass =>
              dtsTransformer.recordStaticField(analyzedClass.name, analyzedClass.compilation));

      // Find the corresponding `.d.ts` file.
      const sourceFileName = sourceFile.fileName;
      const originalDtsFileName = this.dtsMapper.getDtsFileNameFor(sourceFileName);
      const originalDtsContents = readFileSync(originalDtsFileName, 'utf8');

      // Transform the `.d.ts` file based on the recorded source file changes.
      const transformedDtsFileName =
          resolve(this.targetPath, relative(this.sourcePath, originalDtsFileName));
      const transformedDtsContents = dtsTransformer.transform(originalDtsContents, sourceFileName);

      // Add the transformed `.d.ts` file to the list of output files.
      renderedFiles.push({path: transformedDtsFileName, contents: transformedDtsContents});
    }

    return renderedFiles;
  }
开发者ID:KaneFreeman,项目名称:angular,代码行数:33,代码来源:esm2015_renderer.ts


示例4: Error

  entryPoints.forEach(entryPoint => {
    // Are we compiling the Angular core?
    const isCore = entryPoint.name === '@angular/core';

    const compiledFormats = new Set<string>();
    const entryPointPackageJson = entryPoint.packageJson;
    const entryPointPackageJsonPath = AbsoluteFsPath.from(resolve(entryPoint.path, 'package.json'));

    const hasProcessedDts = hasBeenProcessed(entryPointPackageJson, 'typings');

    for (let i = 0; i < propertiesToConsider.length; i++) {
      const property = propertiesToConsider[i] as EntryPointJsonProperty;
      const formatPath = entryPointPackageJson[property];
      const format = getEntryPointFormat(property);

      // No format then this property is not supposed to be compiled.
      if (!formatPath || !format || SUPPORTED_FORMATS.indexOf(format) === -1) continue;

      if (hasBeenProcessed(entryPointPackageJson, property)) {
        compiledFormats.add(formatPath);
        logger.info(`Skipping ${entryPoint.name} : ${property} (already compiled).`);
        continue;
      }

      const isFirstFormat = compiledFormats.size === 0;
      const processDts = !hasProcessedDts && isFirstFormat;

      // We don't break if this if statement fails because we still want to mark
      // the property as processed even if its underlying format has been built already.
      if (!compiledFormats.has(formatPath) && (compileAllFormats || isFirstFormat)) {
        const bundle = makeEntryPointBundle(
            entryPoint.path, formatPath, entryPoint.typings, isCore, property, format, processDts);
        if (bundle) {
          logger.info(`Compiling ${entryPoint.name} : ${property} as ${format}`);
          const transformedFiles = transformer.transform(bundle);
          fileWriter.writeBundle(entryPoint, bundle, transformedFiles);
          compiledFormats.add(formatPath);
        } else {
          logger.warn(
              `Skipping ${entryPoint.name} : ${format} (no valid entry point file for this format).`);
        }
      } else if (!compileAllFormats) {
        logger.info(`Skipping ${entryPoint.name} : ${property} (already compiled).`);
      }

      // Either this format was just compiled or its underlying format was compiled because of a
      // previous property.
      if (compiledFormats.has(formatPath)) {
        markAsProcessed(entryPointPackageJson, entryPointPackageJsonPath, property);
        if (processDts) {
          markAsProcessed(entryPointPackageJson, entryPointPackageJsonPath, 'typings');
        }
      }
    }

    if (compiledFormats.size === 0) {
      throw new Error(
          `Failed to compile any formats for entry-point at (${entryPoint.path}). Tried ${propertiesToConsider}.`);
    }
  });
开发者ID:Cammisuli,项目名称:angular,代码行数:60,代码来源:main.ts


示例5: it

 it("should parse a TS file", () => {
   const parseInfo = parser.parse(['testSrc.ts'], path.resolve(__dirname, '../../mocks/tsParser'));
   const tsModules = parseInfo.moduleSymbols;
   expect(tsModules.length).toEqual(1);
   expect(tsModules[0].exportArray.length).toEqual(3);
   expect(tsModules[0].exportArray.map(i => i.name)).toEqual(['MyClass', 'myFn', 'x']);
 });
开发者ID:angular,项目名称:dgeni-packages,代码行数:7,代码来源:index.spec.ts


示例6: loadSitemapUrls

export function loadSitemapUrls() {
  const pathToSiteMap = path.resolve(__dirname, '../../src/generated/sitemap.xml');
  const xml = readFileSync(pathToSiteMap, 'utf8');
  const urls: string[] = [];
  xml.replace(/<loc>([^<]+)<\/loc>/g, (_, loc) => urls.push(loc.replace('%%DEPLOYMENT_HOST%%', '')));
  return urls;
}
开发者ID:cironunes,项目名称:angular,代码行数:7,代码来源:helpers.ts


示例7: getEntryPointInfo

export function getEntryPointInfo(pkgPath: string, entryPoint: string): EntryPoint|null {
  const packageJsonPath = path.resolve(entryPoint, 'package.json');
  if (!fs.existsSync(packageJsonPath)) {
    return null;
  }

  // If there is `esm2015` then `es2015` will be FESM2015, otherwise ESM2015.
  // If there is `esm5` then `module` will be FESM5, otherwise it will be ESM5.
  const {
    name,
    module: modulePath,
    types,
    typings = types,  // synonymous
    es2015,
    fesm2015 = es2015,   // synonymous
    fesm5 = modulePath,  // synonymous
    esm2015,
    esm5,
    main
  }: EntryPointPackageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));

  // Minimum requirement is that we have typings and one of esm2015 or fesm2015 formats.
  if (!typings || !(fesm2015 || esm2015)) {
    return null;
  }

  // Also we need to have a metadata.json file
  const metadataPath = path.resolve(entryPoint, typings.replace(/\.d\.ts$/, '') + '.metadata.json');
  if (!fs.existsSync(metadataPath)) {
    return null;
  }

  const entryPointInfo: EntryPoint = {
    name,
    package: pkgPath,
    path: entryPoint,
    typings: path.resolve(entryPoint, typings),
  };

  if (esm2015) {
    entryPointInfo.esm2015 = path.resolve(entryPoint, esm2015);
  }
  if (fesm2015) {
    entryPointInfo.fesm2015 = path.resolve(entryPoint, fesm2015);
  }
  if (fesm5) {
    entryPointInfo.fesm5 = path.resolve(entryPoint, fesm5);
  }
  if (esm5) {
    entryPointInfo.esm5 = path.resolve(entryPoint, esm5);
  }
  if (main) {
    entryPointInfo.umd = path.resolve(entryPoint, main);
  }

  return entryPointInfo;
}
开发者ID:foresthz,项目名称:angular,代码行数:57,代码来源:entry_point.ts


示例8: beforeEach

 beforeEach(() => {
   parser = new TsParser(require('dgeni/lib/mocks/log')(false));
   basePath = path.resolve(__dirname, '../../mocks');
   const parseInfo = parser.parse(['tsParser/getDecorators.test.ts'], basePath);
   const moduleExports = parseInfo.moduleSymbols[0].exportArray;
   testClass = moduleExports[0];
   testMethodDeclaration = testClass.members!.get('method' as __String)!.getDeclarations()![0];
   testParameters = (testMethodDeclaration as any).parameters;
 });
开发者ID:angular,项目名称:dgeni-packages,代码行数:9,代码来源:getDecorators.spec.ts


示例9: beforeEach

  beforeEach(() => {
    dgeni = new Dgeni([mockPackage()]);
    injector = dgeni.configureInjector();

    tsProcessor = injector.get('readTypeScriptModules');
    parseTagsProcessor = injector.get('parseTagsProcessor');
    extractTagsProcessor = injector.get('extractTagsProcessor');
    mergeParameterInfoProcessor = injector.get('mergeParameterInfo');
    tsProcessor.basePath = path.resolve(__dirname, '../mocks/readTypeScriptModules');
    tsProcessor.sourceFiles = ['methodParameters.ts'];
  });
开发者ID:angular,项目名称:dgeni-packages,代码行数:11,代码来源:mergeParameterInfo.spec.ts


示例10: resolve

    program.getSourceFiles().map(sourceFile => {
      const decorationAnalysis = decorationAnalyses.get(sourceFile);
      const switchMarkerAnalysis = switchMarkerAnalyses.get(sourceFile);

      // Transform the source files and source maps.
      if (decorationAnalysis || switchMarkerAnalysis) {
        const targetPath = resolve(this.targetPath, relative(this.sourcePath, sourceFile.fileName));
        renderedFiles.push(
            ...this.renderFile(sourceFile, decorationAnalysis, switchMarkerAnalysis, targetPath));
      }
    });
开发者ID:KaneFreeman,项目名称:angular,代码行数:11,代码来源:renderer.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript canvasjs.Chart类代码示例发布时间:2022-05-25
下一篇:
TypeScript canonical-path.relative函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap