File tree 2 files changed +17
-1
lines changed
packages/angular_devkit/core/src/virtual-fs/host
2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -180,7 +180,7 @@ export class SimpleMemoryHost implements Host<{}> {
180
180
path = this . _toAbsolute ( path ) ;
181
181
if ( this . _isDirectory ( path ) ) {
182
182
for ( const [ cachePath ] of this . _cache . entries ( ) ) {
183
- if ( path . startsWith ( cachePath + NormalizedSep ) ) {
183
+ if ( cachePath . startsWith ( path + NormalizedSep ) || cachePath === path ) {
184
184
this . _cache . delete ( cachePath ) ;
185
185
}
186
186
}
Original file line number Diff line number Diff line change @@ -65,6 +65,22 @@ describe('SimpleMemoryHost', () => {
65
65
expect ( host . exists ( normalize ( '/sub/file1' ) ) ) . toBe ( false ) ;
66
66
} ) ;
67
67
68
+ it ( 'can delete directory' , ( ) => {
69
+ const host = new SyncDelegateHost ( new SimpleMemoryHost ( ) ) ;
70
+
71
+ const buffer = stringToFileBuffer ( 'hello' ) ;
72
+
73
+ expect ( host . exists ( normalize ( '/sub/file1' ) ) ) . toBe ( false ) ;
74
+ host . write ( normalize ( '/sub/file1' ) , buffer ) ;
75
+ host . write ( normalize ( '/subfile.2' ) , buffer ) ;
76
+ expect ( host . exists ( normalize ( '/sub/file1' ) ) ) . toBe ( true ) ;
77
+ expect ( host . exists ( normalize ( '/subfile.2' ) ) ) . toBe ( true ) ;
78
+ host . delete ( normalize ( '/sub' ) ) ;
79
+ expect ( host . exists ( normalize ( '/sub/file1' ) ) ) . toBe ( false ) ;
80
+ expect ( host . exists ( normalize ( '/sub' ) ) ) . toBe ( false ) ;
81
+ expect ( host . exists ( normalize ( '/subfile.2' ) ) ) . toBe ( true ) ;
82
+ } ) ;
83
+
68
84
it ( 'can rename' , ( ) => {
69
85
const host = new SyncDelegateHost ( new SimpleMemoryHost ( ) ) ;
70
86
You can’t perform that action at this time.
0 commit comments