Set up reflex for make watch

This commit is contained in:
Benedikt Kulmann
2020-07-01 11:05:33 +02:00
parent 28e72bc5ad
commit f883c5bd0b
8 changed files with 57 additions and 46 deletions
+24
View File
@@ -3,6 +3,7 @@ package assets
import (
"net/http"
"os"
"path"
"github.com/owncloud/ocis-accounts/pkg/config"
"github.com/owncloud/ocis-pkg/v2/log"
@@ -18,6 +19,29 @@ type assets struct {
// Open just implements the HTTP filesystem interface.
func (a assets) Open(original string) (http.File, error) {
if a.config.Asset.Path != "" {
if stat, err := os.Stat(a.config.Asset.Path); err == nil && stat.IsDir() {
custom := path.Join(
a.config.Asset.Path,
original,
)
if _, err := os.Stat(custom); !os.IsNotExist(err) {
f, err := os.Open(custom)
if err != nil {
return nil, err
}
return f, nil
}
} else {
a.logger.Warn().
Str("path", a.config.Asset.Path).
Msg("Assets directory doesn't exist")
}
}
return FS.OpenFile(
CTX,
original,
+3 -3
View File
File diff suppressed because one or more lines are too long
+6
View File
@@ -43,6 +43,11 @@ type Server struct {
AccountsDataPath string
}
// Asset defines the available asset configuration.
type Asset struct {
Path string
}
// Log defines the available logging configuration.
type Log struct {
Level string
@@ -56,6 +61,7 @@ type Config struct {
HTTP HTTP
GRPC GRPC
Server Server
Asset Asset
Log Log
}
+7
View File
@@ -84,5 +84,12 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag {
EnvVars: []string{"ACCOUNTS_DATA_PATH"},
Destination: &cfg.Server.AccountsDataPath,
},
&cli.StringFlag{
Name: "asset-path",
Value: "",
Usage: "Path to custom assets",
EnvVars: []string{"HELLO_ASSET_PATH"},
Destination: &cfg.Asset.Path,
},
}
}