Skip to content

Commit 31facc1

Browse files
committed
Update makefile and path discovery
1 parent 2aca5b7 commit 31facc1

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@ all: build test
66
build:
77
go build -o ${BINARY_PATH}
88

9-
run:
10-
go build -o ${BINARY_PATH}
9+
run: build
1110
${BINARY_NAME} run ~/src/runbook
1211

1312
clean:
1413
go clean
1514
rm ${BINARY_PATH}
1615

16+
install: build
17+
cp -f ./bin/polylint ~/bin/
18+
1719
test:
1820
go test -v .
1921

cmd/root.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,22 @@ func initConfig() {
5757

5858
// Search config in home directory with name ".polylint" (without extension).
5959
viper.AddConfigPath(".")
60+
viper.AddConfigPath("../.")
61+
viper.AddConfigPath("../../.")
6062
viper.AddConfigPath(home)
6163
viper.SetConfigType("yaml")
6264
viper.SetConfigName(".polylint")
6365
}
6466

67+
viper.SetEnvPrefix("POLYLINT")
6568
viper.AutomaticEnv() // read in environment variables that match
6669

6770
if err := viper.ReadInConfig(); err != nil {
68-
fmt.Fprintln(os.Stderr, "Error reading config file:", viper.ConfigFileUsed())
71+
// Error means that it's a non-standard configuration file but that's ok
72+
if err != viper.UnsupportedConfigError("polylint") {
73+
fmt.Fprintf(os.Stderr, "Error reading config file: %s\nError: %e", viper.ConfigFileUsed(), err)
74+
}
75+
} else {
76+
fmt.Printf("Using config file: %s\n", viper.ConfigFileUsed())
6977
}
7078
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ go 1.21.6
44

55
require (
66
github.com/dop251/goja v0.0.0-20240220182346-e401ed450204
7+
github.com/jedib0t/go-pretty/v6 v6.5.8
78
github.com/spf13/cobra v1.8.0
89
github.com/spf13/viper v1.18.2
910
golang.org/x/mod v0.12.0
@@ -17,7 +18,6 @@ require (
1718
github.com/google/pprof v0.0.0-20230207041349-798e818bf904 // indirect
1819
github.com/hashicorp/hcl v1.0.0 // indirect
1920
github.com/inconshreveable/mousetrap v1.1.0 // indirect
20-
github.com/jedib0t/go-pretty/v6 v6.5.8 // indirect
2121
github.com/magiconair/properties v1.8.7 // indirect
2222
github.com/mattn/go-runewidth v0.0.15 // indirect
2323
github.com/mitchellh/mapstructure v1.5.0 // indirect

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
107107
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
108108
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
109109
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
110-
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
111-
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
112110
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
113111
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
114112
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=

0 commit comments

Comments
 (0)