fix(compiler-cli): ensure LogicalProjectPaths always start with a slash (#29627)

Previously, if a matching rootDir ended with a slash then the path
returned from `logicalPathOfFile()` would not start with a slash,
which is inconsistent.

PR Close #29627
This commit is contained in:
Pete Bacon Darwin
2019-04-01 08:54:07 +01:00
committed by Igor Minar
parent ec56354306
commit e02684e609
2 changed files with 17 additions and 1 deletions

View File

@ -31,6 +31,16 @@ describe('logical paths', () => {
expect(fs.logicalPathOfFile(abs('/test/foo.ts'))).toEqual('/foo' as LogicalProjectPath);
expect(fs.logicalPathOfFile(abs('/test/dist/foo.ts'))).toEqual('/foo' as LogicalProjectPath);
});
it('should always return `/` prefixed logical paths', () => {
const rootFs = new LogicalFileSystem([abs('/')]);
expect(rootFs.logicalPathOfFile(abs('/foo/foo.ts')))
.toEqual('/foo/foo' as LogicalProjectPath);
const nonRootFs = new LogicalFileSystem([abs('/test/')]);
expect(nonRootFs.logicalPathOfFile(abs('/test/foo/foo.ts')))
.toEqual('/foo/foo' as LogicalProjectPath);
});
});
describe('utilities', () => {