Skip to content

Commit

Permalink
Add global default config
Browse files Browse the repository at this point in the history
  • Loading branch information
sarjann committed Dec 3, 2023
1 parent b8f3808 commit d36e7d2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ air -c .air.toml
```

You can initialize the `.air.toml` configuration file to the current directory with the default settings running the following command.
You can also create a global default for `.air.toml` in `~/.air.toml`.

```bash
air init
Expand Down
12 changes: 12 additions & 0 deletions runner/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
const (
dftTOML = ".air.toml"
dftConf = ".air.conf"
dftGlobTOML= "~/.air.toml"
airWd = "air_wd"
)

Expand Down Expand Up @@ -207,7 +208,18 @@ func readConfByName(name string) (*Config, error) {
return cfg, err
}

func defaultGlobalConfig() (*Config, error) {
defaultConfigPath, _ := expandPath(dftGlobTOML)
cfg, err := readConfig(defaultConfigPath)
return cfg, err
}

func defaultConfig() Config {
cfg, err := defaultGlobalConfig()
if err == nil {
return *cfg
}

build := cfgBuild{
Cmd: "go build -o ./tmp/main .",
Bin: "./tmp/main",
Expand Down

0 comments on commit d36e7d2

Please sign in to comment.