Skip to content

Commit c2d91cb

Browse files
committed
fe: panic if index.html doesn't exist
1 parent fcc814f commit c2d91cb

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

cmd/fe/main.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,11 @@ Options:
105105

106106
var assets string
107107
if s, ok := utils.Argument(d, "--assets-dir"); ok {
108-
assets = s
108+
abspath, err := filepath.Abs(s)
109+
if err != nil {
110+
log.PanicErrorf(err, "get absolute path of %s failed", s)
111+
}
112+
assets = abspath
109113
} else {
110114
binpath, err := filepath.Abs(filepath.Dir(os.Args[0]))
111115
if err != nil {
@@ -115,12 +119,9 @@ Options:
115119
}
116120
log.Warnf("set assets = %s", assets)
117121

118-
fi, err := os.Stat(assets)
119-
if err != nil {
120-
log.PanicErrorf(err, "get stat of %s failed", assets)
121-
}
122-
if !fi.IsDir() {
123-
log.Panicf("%s is not a directory", assets)
122+
indexFile := filepath.Join(assets, "index.html")
123+
if _, err := os.Stat(indexFile); err != nil {
124+
log.PanicErrorf(err, "get stat of %s failed", indexFile)
124125
}
125126

126127
var loader ConfigLoader

0 commit comments

Comments
 (0)