Skip to content

Commit

Permalink
Automatically create resources folder if it doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
s0nerik committed Apr 19, 2019
1 parent c41bff1 commit e8a50ef
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
12 changes: 12 additions & 0 deletions goloc/goloc.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,18 @@ func Run(
}
}

// Make sure we can access resources dir
if _, err := os.Stat(resDir); err != nil {
if os.IsNotExist(err) {
err := os.MkdirAll(resDir, 0755)
if err != nil {
log.Fatal(err)
}
} else {
log.Fatal(err)
}
}

if p, ok := platform.(Preprocessor); ok {
err := p.Preprocess(PreprocessArgs{ResDir: resDir, Localizations: localizations, Formats: formats, FormatArgs: fArgs, DefaultLocalization: defaultLocalization})
if err != nil {
Expand Down
5 changes: 0 additions & 5 deletions goloc/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,6 @@ func WriteLocalizations(
defLocLang Lang,
defLocPath string,
) (error error) {
// Make sure we can access resources dir
if _, error = os.Stat(dir); error != nil {
return
}

locIndices := map[Lang]int{}
locCounts := localizations.Count()
locStringArgs := &LocalizedStringArgs{}
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var (
)

func main() {
kingpin.Version("0.9.5")
kingpin.Version("0.9.6")
kingpin.Parse()

platform, err := resolver.FindPlatform(*platformName)
Expand Down

0 comments on commit e8a50ef

Please sign in to comment.