fsx: Remove environment references
This commit removes the reference to the environment from the fsx package.
This commit is contained in:
parent
5a43ecfaeb
commit
3263920d6b
25 changed files with 167 additions and 183 deletions
|
|
@ -24,7 +24,7 @@ type Parser[T any] func(env environment.Environment, s string) (T, error)
|
|||
|
||||
// ParseAbspath checks that s is an absolute path and returns it as-is
|
||||
func ParseAbspath(env environment.Environment, s string) (string, error) {
|
||||
if !fsx.IsDirectory(env, s) {
|
||||
if !fsx.IsDirectory(s) {
|
||||
return "", errors.Errorf("%q does not exist or is not a directory", s)
|
||||
}
|
||||
return s, nil
|
||||
|
|
@ -32,7 +32,7 @@ func ParseAbspath(env environment.Environment, s string) (string, error) {
|
|||
|
||||
// ParseFile checks that s is a valid file and returns it as-is
|
||||
func ParseFile(env environment.Environment, s string) (string, error) {
|
||||
if !fsx.IsFile(env, s) {
|
||||
if !fsx.IsFile(s) {
|
||||
return "", errors.Errorf("%q does not exist or is not a regular file", s)
|
||||
}
|
||||
return s, nil
|
||||
|
|
|
|||
|
|
@ -39,14 +39,14 @@ func (pcfg PathsConfig) UsingDistilleryExecutable(env environment.Environment) b
|
|||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return fsx.SameFile(env, exe, pcfg.ExecutablePath())
|
||||
return fsx.SameFile(exe, pcfg.ExecutablePath())
|
||||
}
|
||||
|
||||
// CurrentExecutable returns the path to the current executable being used.
|
||||
// When it does not exist, falls back to the default executable.
|
||||
func (pcfg PathsConfig) CurrentExecutable(env environment.Environment) string {
|
||||
exe, err := os.Executable()
|
||||
if err != nil || !fsx.IsFile(env, exe) {
|
||||
if err != nil || !fsx.IsFile(exe) {
|
||||
return pcfg.ExecutablePath()
|
||||
}
|
||||
return exe
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ func ValidateFile(env environment.Environment, path *string, dflt string) error
|
|||
if *path == "" {
|
||||
*path = dflt
|
||||
}
|
||||
if !fsx.IsFile(env, *path) {
|
||||
if !fsx.IsFile(*path) {
|
||||
return errors.Errorf("%q does not exist or is not a file", *path)
|
||||
}
|
||||
return nil
|
||||
|
|
@ -20,7 +20,7 @@ func ValidateDirectory(env environment.Environment, path *string, dflt string) e
|
|||
if *path == "" {
|
||||
*path = dflt
|
||||
}
|
||||
if !fsx.IsDirectory(env, *path) {
|
||||
if !fsx.IsDirectory(*path) {
|
||||
return errors.Errorf("%q does not exist or is not a directory", *path)
|
||||
}
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue