Make all paths absolute

Fixes #200
This commit is contained in:
Neale Pickett 2024-04-09 11:54:39 -06:00
parent dfecd100b8
commit 7c5b5b5ccf
2 changed files with 24 additions and 6 deletions

4
.gitignore vendored
View File

@ -5,6 +5,6 @@
__debug_bin
*.tar.gz
transpile
mothd
winmoth.*.zip
*.exe
/mothd
/*.exe

View File

@ -6,6 +6,7 @@ import (
"log"
"mime"
"os"
"path/filepath"
"time"
"github.com/spf13/afero"
@ -54,21 +55,38 @@ func main() {
)
flag.Parse()
var theme *Theme
osfs := afero.NewOsFs()
theme := NewTheme(afero.NewBasePathFs(osfs, *themePath))
if p, err := filepath.Abs(*themePath); err != nil {
log.Fatal(err)
} else {
theme = NewTheme(afero.NewBasePathFs(osfs, p))
}
config := Configuration{}
var provider PuzzleProvider
provider = NewMothballs(afero.NewBasePathFs(osfs, *mothballPath))
if p, err := filepath.Abs(*mothballPath); err != nil {
log.Fatal(err)
} else {
provider = NewMothballs(afero.NewBasePathFs(osfs, p))
}
if *puzzlePath != "" {
provider = NewTranspilerProvider(afero.NewBasePathFs(osfs, *puzzlePath))
if p, err := filepath.Abs(*puzzlePath); err != nil {
log.Fatal(err)
} else {
provider = NewTranspilerProvider(afero.NewBasePathFs(osfs, p))
}
config.Devel = true
log.Println("-=- You are in development mode, champ! -=-")
}
var state StateProvider
state = NewState(afero.NewBasePathFs(osfs, *statePath))
if p, err := filepath.Abs(*statePath); err != nil {
log.Fatal(err)
} else {
state = NewState(afero.NewBasePathFs(osfs, p))
}
if config.Devel {
state = NewDevelState(state)
}