diff --git a/.gitignore b/.gitignore index 795754d..af704a7 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ biome # Actual biome config (only meant to be exclude from this repo, should be in your own repos) .biome.yaml +.biome.yml # Test binary, built with `go test -c` *.test diff --git a/README.md b/README.md index a3c1b42..353dfe3 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ $ onstaging ./bin/ci/deploy-service.sh - :white_check_mark: Implement goreleaser for binary building - :white_check_mark: Use semantic versioning - :white_check_mark: Add a version command -- Accept all valid yaml file extensions +- :white_check_mark: Accept all valid yaml file extensions - Build a Drone CI/CD pipeline - Implement some tests - Loading Environment variables from a .env file diff --git a/parser/parser.go b/parser/parser.go index 157e625..1453ecb 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -15,15 +15,17 @@ import ( ) var LoadedBiome *config.BiomeConfig -const BiomeConfigFileName = ".biome.yaml" +var BiomeConfigFileNames = []string{".biome.yaml", ".biome.yml"} -// LoadBiome will find the nearest .biome.yaml in this priority order +// LoadBiome will find the nearest .biome.[yml|yaml] in this priority order // - Current Directory // - Home Directory func LoadBiome(biomeName string) error { biomeConfigPaths := []string{ - getCdFilePath(), - getHomeDirFilePath(), + getCdFilePath(BiomeConfigFileNames[0]), + getCdFilePath(BiomeConfigFileNames[1]), + getHomeDirFilePath(BiomeConfigFileNames[0]), + getHomeDirFilePath(BiomeConfigFileNames[1]), } // Reset the loaded biome @@ -95,7 +97,7 @@ func tryLoadBiomeConfig(fPath string, biomeName string) error { } func findBiomeInFileContents(data []byte, biomeName string) (*config.BiomeConfig, error) { - + // Setup the reader and decoder r := bytes.NewReader(data) decoder := yaml.NewDecoder(r) @@ -120,22 +122,22 @@ func findBiomeInFileContents(data []byte, biomeName string) (*config.BiomeConfig return nil, nil } -func getCdFilePath() string { +func getCdFilePath(fname string) string { cdPath, err := os.Getwd() if err != nil { log.Fatalf("unable to get current directory: %v", err) } - return path.Join(cdPath, BiomeConfigFileName) + return path.Join(cdPath, fname) } -func getHomeDirFilePath() string { +func getHomeDirFilePath(fname string) string { currentUser, err := user.Current() if err != nil { log.Fatalf("unable to get current user: %v", err) } - return path.Join(currentUser.HomeDir, BiomeConfigFileName) + return path.Join(currentUser.HomeDir, fname) } func fileExists(path string) bool {