Skip to content

Commit

Permalink
Run init even if config is found
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathew Byrne committed Aug 6, 2018
1 parent 52b7879 commit fb03bad
Showing 1 changed file with 16 additions and 21 deletions.
37 changes: 16 additions & 21 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,28 +105,23 @@ func initConfig() *codegen.Config {
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
} else if config != nil {
fmt.Fprintln(os.Stderr, "config file already exists")
os.Exit(0)
}
} else {
config, err = codegen.LoadConfigFromDefaultLocations()
if os.IsNotExist(errors.Cause(err)) {
if configFilename == "" {
configFilename = "gqlgen.yml"
}
config = codegen.DefaultConfig()
config.Resolver = codegen.PackageConfig{
Filename: "resolver.go",
Type: "Resolver",
}
} else if config != nil {
fmt.Fprintln(os.Stderr, "config file already exists")
os.Exit(0)
} else if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
return config
}

config, err = codegen.LoadConfigFromDefaultLocations()
if config != nil {
return config
} else if !os.IsNotExist(errors.Cause(err)) {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}

configFilename = "gqlgen.yml"
config = codegen.DefaultConfig()
config.Resolver = codegen.PackageConfig{
Filename: "resolver.go",
Type: "Resolver",
}

if schemaFilename != "" {
Expand Down

0 comments on commit fb03bad

Please sign in to comment.