@@ -5,40 +5,32 @@ import (
6 "path/filepath"
6 "path/filepath"
8− "sync"
8+ "sync/atomic"
11−const InitFlagFilename = "init"
12+ InitFlagFilename = "init"
13type ProjectInitFlag struct {
15type ProjectInitFlag struct {
14 Initialized bool `json:"initialized"`
16 Initialized bool `json:"initialized"`
17// TODO: we need to remove the global config instance keeping it now just until everything is migrated
19// TODO: we need to remove the global config instance keeping it now just until everything is migrated
19− instance *Config
20+var instance atomic.Pointer[Config]
25func Init(workingDir string, debug bool) (*Config, error) {
22func Init(workingDir string, debug bool) (*Config, error) {
29− cwd = workingDir
23+ cfg, err := Load(workingDir, debug)
30− var cfg *Config
24+ if err != nil {
31− cfg, err = Load(cwd, debug)
25+ return nil, err
35−
27+ instance.Store(cfg)
36− return instance, err
28+ return instance.Load(), nil
39func Get() *Config {
31func Get() *Config {
40− wg.Wait()
32+ cfg := instance.Load()
41− return instance
33+ return cfg
44func ProjectNeedsInitialization() (bool, error) {
36func ProjectNeedsInitialization() (bool, error) {