Skip to content

Commit

Permalink
fix: nil derefence on gazelle update-repos
Browse files Browse the repository at this point in the history
Signed-off-by: James Bartlett <james@gimletlabs.ai>
  • Loading branch information
JamesMBartlett authored and ColinHeathman committed Oct 20, 2023
1 parent d8aece3 commit c85ea54
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions gazelle/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,22 @@ func (v *Visibility) Set(value string) error {
return nil
}

func newJsConfigsWithRootConfig() JsConfigs {
rootConfig := NewJsConfig()
rootConfig.JSRoot = "."
rootConfig.CollectedAssets = make(map[string]bool)
return JsConfigs{
"": rootConfig,
}
}

// RegisterFlags registers command-line flags used by the extension. This
// method is called once with the root configuration when Gazelle
// starts. RegisterFlags may set an initial values in Config.Exts. When flags
// are set, they should modify these values.
func (lang *JS) RegisterFlags(fs *flag.FlagSet, cmd string, c *config.Config) {}
func (lang *JS) RegisterFlags(fs *flag.FlagSet, cmd string, c *config.Config) {
c.Exts[languageName] = newJsConfigsWithRootConfig()
}

// CheckFlags validates the configuration after command line flags are parsed.
// This is called once with the root configuration when Gazelle starts.
Expand Down Expand Up @@ -249,12 +260,7 @@ func (*JS) Configure(c *config.Config, rel string, f *rule.File) {

// Create the root config.
if _, exists := c.Exts[languageName]; !exists {
rootConfig := NewJsConfig()
rootConfig.JSRoot = "."
rootConfig.CollectedAssets = make(map[string]bool)
c.Exts[languageName] = JsConfigs{
"": rootConfig,
}
c.Exts[languageName] = newJsConfigsWithRootConfig()
}

jsConfigs := c.Exts[languageName].(JsConfigs)
Expand Down

0 comments on commit c85ea54

Please sign in to comment.