feat: include func support (#1187)

* feat: include func support

Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
yxxhero
2023-12-04 21:51:01 +08:00
committed by GitHub
parent 06504477f6
commit 7d6ed97333
20 changed files with 380 additions and 53 deletions
+5 -1
View File
@@ -30,6 +30,7 @@ type FileSystem struct {
Glob func(string) ([]string, error)
FileExistsAt func(string) bool
DirectoryExistsAt func(string) bool
Dir func(string) string
Stat func(string) (os.FileInfo, error)
Getwd func() (string, error)
Chdir func(string) error
@@ -41,11 +42,11 @@ func DefaultFileSystem() *FileSystem {
dfs := FileSystem{
ReadDir: os.ReadDir,
DeleteFile: os.Remove,
Stat: os.Stat,
Glob: filepath.Glob,
Getwd: os.Getwd,
Chdir: os.Chdir,
EvalSymlinks: filepath.EvalSymlinks,
Dir: filepath.Dir,
}
dfs.Stat = dfs.stat
@@ -96,6 +97,9 @@ func FromFileSystem(params FileSystem) *FileSystem {
if params.EvalSymlinks != nil {
dfs.EvalSymlinks = params.EvalSymlinks
}
if params.Dir != nil {
dfs.Dir = params.Dir
}
return dfs
}