From 41acb0b09ef7d3046d9b62aac65925da7dedb07c Mon Sep 17 00:00:00 2001 From: Mike Landau Date: Mon, 14 Oct 2024 12:41:20 -0700 Subject: [PATCH] [autodetect] Fix autodetect --- internal/devconfig/configfile/file.go | 5 +++++ pkg/autodetect/autodetect.go | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/internal/devconfig/configfile/file.go b/internal/devconfig/configfile/file.go index 0f6d9b79857..0ecb976e0ea 100644 --- a/internal/devconfig/configfile/file.go +++ b/internal/devconfig/configfile/file.go @@ -115,6 +115,11 @@ func (c *ConfigFile) SaveTo(path string) error { return os.WriteFile(filepath.Join(path, DefaultName), c.Bytes(), 0o644) } +// TODO: Can we remove SaveTo and just use Save()? +func (c *ConfigFile) Save() error { + return c.SaveTo(c.AbsRootPath) +} + // Get returns the package with the given versionedName func (c *ConfigFile) GetPackage(versionedName string) (*Package, bool) { name, version := parseVersionedName(versionedName) diff --git a/pkg/autodetect/autodetect.go b/pkg/autodetect/autodetect.go index a4ac0c5710b..12ef7c8a478 100644 --- a/pkg/autodetect/autodetect.go +++ b/pkg/autodetect/autodetect.go @@ -13,7 +13,11 @@ func InitConfig(ctx context.Context, path string) error { return err } - return populateConfig(ctx, path, config) + if err = populateConfig(ctx, path, config); err != nil { + return err + } + + return config.Root.Save() } func DryRun(ctx context.Context, path string) ([]byte, error) {