@@ -13,34 +13,21 @@ import (
1313var fakeTsVersion = "FakeTSVersion"
1414
1515type FsHandlingBuildInfo struct {
16- fs vfs.FS
16+ vfs.FS
1717}
1818
19- var _ vfs.FS = (* FsHandlingBuildInfo )(nil )
20-
2119func NewFsHandlingBuildInfo (fs vfs.FS ) * FsHandlingBuildInfo {
22- return & FsHandlingBuildInfo {
23- fs : fs ,
24- }
20+ return & FsHandlingBuildInfo {FS : fs }
2521}
2622
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 )
3825}
3926
4027// ReadFile reads the file specified by path and returns the content.
4128// If the file fails to be read, ok will be false.
4229func (f * FsHandlingBuildInfo ) ReadFile (path string ) (contents string , ok bool ) {
43- contents , ok = f .fs . ReadFile (path )
30+ contents , ok = f .InnerReadFile (path )
4431 if ok && tspath .FileExtensionIs (path , tspath .ExtensionTsBuildInfo ) {
4532 // read buildinfo and modify version
4633 var buildInfo incremental.BuildInfo
@@ -71,42 +58,10 @@ func (f *FsHandlingBuildInfo) WriteFile(path string, data string, writeByteOrder
7158 data = string (newData )
7259 }
7360 // 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 {
7562 return fmt .Errorf ("testFs.WriteFile: failed to write readable build info: %w" , err )
7663 }
7764 }
7865 }
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 )
11267}
0 commit comments