Skip to content

Commit

Permalink
fix: utils/utils.go: fix create boilerplate directoy to current worki…
Browse files Browse the repository at this point in the history
…ng directory on Windows and refs other XDG_DATA_HOME and LOCALAPPDATA (#62)

* fix: utils/utils.go: fix create directory on windows
  On Windows, create boiler plate directory to current working directory.
  move this directory to LOCALAPPDATA directory

add: utils/utils.go: boiler plate directory refs "XDG_DATA_HOME"
  create boiler directory under the XDG_DATA_HOME directory,
  if your os set set XDG Base directory.

add: .editorconfig:
  editor tab setting file for go source edit.

* fix: utils.go: fix boilerplatesDir not hidden in XDG Base & LOCALAPPDATA

* chore: remove editorconfig
  • Loading branch information
atsushifx authored Dec 14, 2023
1 parent df264e3 commit 824fa13
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,36 @@ import (
"io/fs"
"os"
"path/filepath"
"runtime"
"sort"
"strings"

"github.com/go-git/go-git/v5"
)

func RepoDir() string {
const gitignoreBoilerplatesDir = "gitignore-boilerplates"
const gitignoreBoilerplatesHiddenDir = "." + gitignoreBoilerplatesDir

override := os.Getenv("GIBO_BOILERPLATES")
if len(override) > 0 {
return override
}
return filepath.Join(os.Getenv("HOME"), ".gitignore-boilerplates")

override = os.Getenv("XDG_DATA_HOME")
if len(override) > 0 {
return filepath.Join(override, "gibo", gitignoreBoilerplatesDir)
}

if runtime.GOOS == "windows" {
override := os.Getenv("LOCALAPPDATA")
if len(override) > 0 {
return filepath.Join(override, gitignoreBoilerplatesDir)
}
}

homeDir, _ := os.UserHomeDir()
return filepath.Join(homeDir, gitignoreBoilerplatesHiddenDir)
}

func cloneRepo(repo string) error {
Expand Down

0 comments on commit 824fa13

Please sign in to comment.