@@ -13,34 +13,21 @@ import (
13
13
var fakeTsVersion = "FakeTSVersion"
14
14
15
15
type FsHandlingBuildInfo struct {
16
- fs vfs.FS
16
+ vfs.FS
17
17
}
18
18
19
- var _ vfs.FS = (* FsHandlingBuildInfo )(nil )
20
-
21
19
func NewFsHandlingBuildInfo (fs vfs.FS ) * FsHandlingBuildInfo {
22
- return & FsHandlingBuildInfo {
23
- fs : fs ,
24
- }
20
+ return & FsHandlingBuildInfo {FS : fs }
25
21
}
26
22
27
- func (f * FsHandlingBuildInfo ) FS () vfs.FS {
28
- return f .fs
29
- }
30
-
31
- func (f * FsHandlingBuildInfo ) UseCaseSensitiveFileNames () bool {
32
- return f .fs .UseCaseSensitiveFileNames ()
33
- }
34
-
35
- // FileExists returns true if the file exists.
36
- func (f * FsHandlingBuildInfo ) FileExists (path string ) bool {
37
- return f .fs .FileExists (path )
23
+ func (f * FsHandlingBuildInfo ) InnerReadFile (path string ) (contents string , ok bool ) {
24
+ return f .FS .ReadFile (path )
38
25
}
39
26
40
27
// ReadFile reads the file specified by path and returns the content.
41
28
// If the file fails to be read, ok will be false.
42
29
func (f * FsHandlingBuildInfo ) ReadFile (path string ) (contents string , ok bool ) {
43
- contents , ok = f .fs . ReadFile (path )
30
+ contents , ok = f .InnerReadFile (path )
44
31
if ok && tspath .FileExtensionIs (path , tspath .ExtensionTsBuildInfo ) {
45
32
// read buildinfo and modify version
46
33
var buildInfo incremental.BuildInfo
@@ -71,42 +58,10 @@ func (f *FsHandlingBuildInfo) WriteFile(path string, data string, writeByteOrder
71
58
data = string (newData )
72
59
}
73
60
// Write readable build info version
74
- if err := f .fs .WriteFile (path + ".readable.baseline.txt" , toReadableBuildInfo (& buildInfo , data ), false ); err != nil {
61
+ if err := f .FS .WriteFile (path + ".readable.baseline.txt" , toReadableBuildInfo (& buildInfo , data ), false ); err != nil {
75
62
return fmt .Errorf ("testFs.WriteFile: failed to write readable build info: %w" , err )
76
63
}
77
64
}
78
65
}
79
- return f .fs .WriteFile (path , data , writeByteOrderMark )
80
- }
81
-
82
- // Removes `path` and all its contents. Will return the first error it encounters.
83
- func (f * FsHandlingBuildInfo ) Remove (path string ) error {
84
- return f .fs .Remove (path )
85
- }
86
-
87
- // DirectoryExists returns true if the path is a directory.
88
- func (f * FsHandlingBuildInfo ) DirectoryExists (path string ) bool {
89
- return f .fs .DirectoryExists (path )
90
- }
91
-
92
- // GetAccessibleEntries returns the files/directories in the specified directory.
93
- // If any entry is a symlink, it will be followed.
94
- func (f * FsHandlingBuildInfo ) GetAccessibleEntries (path string ) vfs.Entries {
95
- return f .fs .GetAccessibleEntries (path )
96
- }
97
-
98
- func (f * FsHandlingBuildInfo ) Stat (path string ) vfs.FileInfo {
99
- return f .fs .Stat (path )
100
- }
101
-
102
- // WalkDir walks the file tree rooted at root, calling walkFn for each file or directory in the tree.
103
- // It is has the same behavior as [fs.WalkDir], but with paths as [string].
104
- func (f * FsHandlingBuildInfo ) WalkDir (root string , walkFn vfs.WalkDirFunc ) error {
105
- return f .fs .WalkDir (root , walkFn )
106
- }
107
-
108
- // Realpath returns the "real path" of the specified path,
109
- // following symlinks and correcting filename casing.
110
- func (f * FsHandlingBuildInfo ) Realpath (path string ) string {
111
- return f .fs .Realpath (path )
66
+ return f .FS .WriteFile (path , data , writeByteOrderMark )
112
67
}
0 commit comments