Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:
- '**'
jobs:
lint:
# no need to lint on main
if: github.ref != 'refs/heads/main'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
Expand Down
16 changes: 15 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,29 @@ func initConfig() {
if cfgFile != "" {
// Use config file from the flag.
viper.SetConfigFile(cfgFile)
_, err := os.Stat(cfgFile)
// If the specified file does not exist, fail.
cobra.CheckErr(err)

} else {
// use the working directory as a primary search path
pwd, err := os.Getwd()
cobra.CheckErr(err)
// Find home directory.
home, err := os.UserHomeDir()
cobra.CheckErr(err)

// Search config in home directory with name ".fmlint.yaml"
// Search directories for a config file.
// The first added paths take precedence.
viper.AddConfigPath(pwd)
viper.AddConfigPath(home)

viper.SetConfigType("yaml")
viper.SetConfigName(".fmlint")
// when the config file is found, print it
if viper.ConfigFileUsed() != "" {
fmt.Printf("Config file name: %s\n", viper.ConfigFileUsed())
}
}

viper.AutomaticEnv() // read in environment variables that match
Expand Down
Loading