File tree 2 files changed +16
-2
lines changed
packages/workspace/src/utils
2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change 1
1
import { fs , vol } from 'memfs' ;
2
2
import { stripIndents } from '@angular-devkit/core/src/utils/literals' ;
3
- import { createDirectory } from './fileutils' ;
3
+ import { createDirectory , isRelativePath } from './fileutils' ;
4
4
5
5
jest . mock ( 'fs' , ( ) => require ( 'memfs' ) . fs ) ;
6
6
jest . mock ( './app-root' , ( ) => ( { appRootPath : '/root' } ) ) ;
@@ -35,4 +35,18 @@ describe('fileutils', () => {
35
35
expect ( fs . statSync ( '/root/b/c' ) . isDirectory ( ) ) . toBe ( true ) ;
36
36
} ) ;
37
37
} ) ;
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
+ } ) ;
38
52
} ) ;
Original file line number Diff line number Diff line change @@ -112,5 +112,5 @@ export function renameSync(
112
112
}
113
113
114
114
export function isRelativePath ( path : string ) : boolean {
115
- return path . startsWith ( './' ) || path . startsWith ( '../' ) ;
115
+ return path === '.' || path . startsWith ( './' ) || path . startsWith ( '../' ) ;
116
116
}
You can’t perform that action at this time.
0 commit comments