default behavior for environment.LoadRoot was returning nil when it should have been returning an env_core.Root stub (#383)

This commit is contained in:
Michael Quigley 2023-07-31 18:00:06 -04:00
parent 349d251c84
commit 5f9c2c769f
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
2 changed files with 16 additions and 6 deletions

View File

@ -13,7 +13,7 @@ func LoadRoot() (env_core.Root, error) {
} else if assert, err := env_v0_3.Assert(); assert && err == nil {
return env_v0_3.Load()
} else {
return nil, err
return env_v0_4.Default()
}
}

View File

@ -18,6 +18,19 @@ type Root struct {
env *env_core.Environment
}
func Default() (*Root, error) {
r := &Root{}
root, err := rootDir()
if err != nil {
return nil, err
}
r.meta = &env_core.Metadata{
V: V,
RootPath: root,
}
return r, nil
}
func Assert() (bool, error) {
exists, err := rootExists()
if err != nil {
@ -55,14 +68,11 @@ func Load() (*Root, error) {
}
} else {
root, err := rootDir()
root, err := Default()
if err != nil {
return nil, err
}
r.meta = &env_core.Metadata{
V: V,
RootPath: root,
}
r = root
}
return r, nil
}