Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8c85bf9

Browse files
committedOct 9, 2020
fix(core): fix resolving projects for imports to '.' (#3839)
1 parent 6377cef commit 8c85bf9

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed
 

‎packages/workspace/src/utils/fileutils.spec.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { fs, vol } from 'memfs';
22
import { stripIndents } from '@angular-devkit/core/src/utils/literals';
3-
import { createDirectory } from './fileutils';
3+
import { createDirectory, isRelativePath } from './fileutils';
44

55
jest.mock('fs', () => require('memfs').fs);
66
jest.mock('./app-root', () => ({ appRootPath: '/root' }));
@@ -35,4 +35,18 @@ describe('fileutils', () => {
3535
expect(fs.statSync('/root/b/c').isDirectory()).toBe(true);
3636
});
3737
});
38+
39+
describe('isRelativePath()', () => {
40+
it('should return true for deeper imports', () => {
41+
expect(isRelativePath('.')).toEqual(true);
42+
expect(isRelativePath('./file')).toEqual(true);
43+
});
44+
it('should return true for upper imports', () => {
45+
expect(isRelativePath('../file')).toEqual(true);
46+
});
47+
it('should return false for absolute imports', () => {
48+
expect(isRelativePath('file')).toEqual(false);
49+
expect(isRelativePath('@nrwl/angular')).toEqual(false);
50+
});
51+
});
3852
});

‎packages/workspace/src/utils/fileutils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,5 +112,5 @@ export function renameSync(
112112
}
113113

114114
export function isRelativePath(path: string): boolean {
115-
return path.startsWith('./') || path.startsWith('../');
115+
return path === '.' || path.startsWith('./') || path.startsWith('../');
116116
}

0 commit comments

Comments
 (0)
Please sign in to comment.