mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-01-29 20:10:56 -08:00
refactor(shell): use fs instead of os for parent
This commit is contained in:
parent
cbd6518faf
commit
52b01aff63
|
@ -654,12 +654,12 @@ func (env *ShellEnvironment) HasParentFilePath(path string) (*FileInfo, error) {
|
|||
defer env.Trace(time.Now(), "HasParentFilePath", path)
|
||||
currentFolder := env.Pwd()
|
||||
for {
|
||||
searchPath := filepath.Join(currentFolder, path)
|
||||
info, err := os.Stat(searchPath)
|
||||
fileSystem := os.DirFS(currentFolder)
|
||||
info, err := fs.Stat(fileSystem, path)
|
||||
if err == nil {
|
||||
return &FileInfo{
|
||||
ParentFolder: currentFolder,
|
||||
Path: searchPath,
|
||||
Path: filepath.Join(currentFolder, path),
|
||||
IsDir: info.IsDir(),
|
||||
}, nil
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ func BenchmarkInit(b *testing.B) {
|
|||
func BenchmarkPrimary(b *testing.B) {
|
||||
cmd := cli.RootCmd
|
||||
// needs to be a non-existing file as we panic otherwise
|
||||
cmd.SetArgs([]string{"print", "primary", "--config", "err.omp.json", "--pwd", "/Users/jan/Code/oh-my-posh/src"})
|
||||
cmd.SetArgs([]string{"print", "primary", "--config", "err.omp.json", "--pwd", "/Users/jan/Code/oh-my-posh/src", "--shell", "fish"})
|
||||
out := bytes.NewBufferString("")
|
||||
cmd.SetOut(out)
|
||||
|
||||
|
|
Loading…
Reference in a new issue