How to use the canonical-path.sep function in canonical-path

To help you get started, we’ve selected a few canonical-path examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github angular / dgeni-packages / typescript / src / services / TsParser / FileInfo.spec.ts View on Github external
it('should normalize path separators to `/`', () => {
      const parseInfo = parser.parse(['tsParser/testSrc.ts'], basePath);
      const module = parseInfo.moduleSymbols[0];
      let fileInfo;

      path.sep = '\\';
      fs.realpathSync.and.returnValue('C:\\Foo\\bar.ts');
      fileInfo = new FileInfo(module.exportArray[0].declarations![0], basePath);

      expect(fileInfo.realFilePath).toBe('C:/Foo/bar.ts');

      path.sep = '/';
      fs.realpathSync.and.returnValue('/Foo/bar.ts');
      fileInfo = new FileInfo(module.exportArray[0].declarations![0], basePath);

      expect(fileInfo.realFilePath).toBe('/Foo/bar.ts');
    });
  });
github angular / dgeni-packages / typescript / src / services / TsParser / FileInfo.spec.ts View on Github external
describe('getRealFilePath()', () => {
    const originalPathSep = path.sep;
    afterEach(() => path.sep = originalPathSep);

    it('should call `fs.realpathSync()`', () => {
      const parseInfo = parser.parse(['tsParser/testSrc.ts'], basePath);
      const module = parseInfo.moduleSymbols[0];
      const fileInfo = new FileInfo(module.exportArray[0].declarations![0], basePath);

      expect(fs.realpathSync).toHaveBeenCalledWith(fileInfo.filePath);
    });

    it('should normalize path separators to `/`', () => {
      const parseInfo = parser.parse(['tsParser/testSrc.ts'], basePath);
      const module = parseInfo.moduleSymbols[0];
      let fileInfo;

      path.sep = '\\';
github angular / dgeni-packages / typescript / src / services / TsParser / FileInfo.ts View on Github external
getRealFilePath(filePath: string): string {
    return realpathSync(filePath).replace(RegExp('\\' + path.sep, 'g'), '/');
  }
}

canonical-path

paths that always use forward slashes

MIT
Latest version published 6 years ago

Package Health Score

50 / 100
Full package analysis