@@ -14,7 +14,7 @@ import { createDeferred } from '../utils/async';
14
14
import { getOSType , OSType } from '../utils/platform' ;
15
15
import {
16
16
FileStat , FileType ,
17
- IFileSystem , IRawFileSystem ,
17
+ IFileSystem , IFileSystemUtils , IRawFileSystem ,
18
18
TemporaryFile , WriteStream
19
19
} from './types' ;
20
20
@@ -63,10 +63,9 @@ interface IRawFSExtra {
63
63
createWriteStream ( dest : string ) : fsextra . WriteStream ;
64
64
}
65
65
66
- // Later we will rename "FileSystem" to "FileSystemUtils" and
67
- // "RawFileSystem" to "FileSystem".
66
+ // Later we will drop "FileSystem", switching usage to
67
+ // "FileSystemUtils" and then rename " RawFileSystem" to "FileSystem".
68
68
69
- @injectable ( )
70
69
class RawFileSystem {
71
70
constructor (
72
71
private readonly nodefs : IRawFS = fs ,
@@ -168,8 +167,9 @@ class RawFileSystem {
168
167
}
169
168
}
170
169
170
+ // more aliases (to cause less churn)
171
171
@injectable ( )
172
- export class FileSystem implements IFileSystem {
172
+ export class FileSystemUtils implements IFileSystemUtils {
173
173
constructor (
174
174
private readonly isWindows = ( getOSType ( ) === OSType . Windows ) ,
175
175
//public readonly raw: IFileSystem = {}
@@ -179,14 +179,6 @@ export class FileSystem implements IFileSystem {
179
179
//****************************
180
180
// aliases
181
181
182
- public async readFile ( filename : string ) : Promise < string > {
183
- return this . raw . readText ( filename ) ;
184
- }
185
-
186
- public async writeFile ( filename : string , data : { } ) : Promise < void > {
187
- return this . raw . writeText ( filename , data ) ;
188
- }
189
-
190
182
public async createDirectory ( dirname : string ) : Promise < void > {
191
183
return this . raw . mkdirp ( dirname ) ;
192
184
}
@@ -199,22 +191,6 @@ export class FileSystem implements IFileSystem {
199
191
return this . raw . rmfile ( filename ) ;
200
192
}
201
193
202
- public async chmod ( filename : string , mode : string ) : Promise < void > {
203
- return this . raw . chmod ( filename , mode ) ;
204
- }
205
-
206
- public async copyFile ( src : string , dest : string ) : Promise < void > {
207
- return this . raw . copyFile ( src , dest ) ;
208
- }
209
-
210
- public readFileSync ( filename : string ) : string {
211
- return this . raw . readTextSync ( filename ) ;
212
- }
213
-
214
- public createWriteStream ( filename : string ) : WriteStream {
215
- return this . raw . createWriteStream ( filename ) ;
216
- }
217
-
218
194
//****************************
219
195
// helpers
220
196
@@ -336,3 +312,30 @@ export class FileSystem implements IFileSystem {
336
312
} ) ;
337
313
}
338
314
}
315
+
316
+ @injectable ( )
317
+ export class FileSystem extends FileSystemUtils implements IFileSystem {
318
+ public async readFile ( filename : string ) : Promise < string > {
319
+ return this . raw . readText ( filename ) ;
320
+ }
321
+
322
+ public async writeFile ( filename : string , data : { } ) : Promise < void > {
323
+ return this . raw . writeText ( filename , data ) ;
324
+ }
325
+
326
+ public async chmod ( filename : string , mode : string ) : Promise < void > {
327
+ return this . raw . chmod ( filename , mode ) ;
328
+ }
329
+
330
+ public async copyFile ( src : string , dest : string ) : Promise < void > {
331
+ return this . raw . copyFile ( src , dest ) ;
332
+ }
333
+
334
+ public readFileSync ( filename : string ) : string {
335
+ return this . raw . readTextSync ( filename ) ;
336
+ }
337
+
338
+ public createWriteStream ( filename : string ) : WriteStream {
339
+ return this . raw . createWriteStream ( filename ) ;
340
+ }
341
+ }
0 commit comments