From d695bb34cc603b5489cb396b45cdaa6174f83b84 Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Sun, 16 May 2021 15:53:30 +0530 Subject: [PATCH] Prioritise --static-dir on init when no assets are embedded. When no static assets are found on init, i.e., when a binary without stuffbin assets are loaded, the app looks for all necessary static files in the working dir, including the `./static/*` path which renders the `--static-dir` flag irrelevant. This patch gives `--static-dir`, if set, precedence over `./static/*` when loading assets from the working dir when a binary is not stuffed with static files. Closes #340. --- cmd/init.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/init.go b/cmd/init.go index 5dd3811..aa983e6 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -126,10 +126,6 @@ func initFS(staticDir, i18nDir string) stuffbin.FileSystem { "config.toml.sample", "queries.sql", "schema.sql", - "static/email-templates", - - // Alias /static/public to /public for the HTTP fileserver. - "static/public:/public", // The frontend app's static assets are aliased to /frontend // so that they are accessible at /frontend/js/* etc. @@ -139,6 +135,11 @@ func initFS(staticDir, i18nDir string) stuffbin.FileSystem { "i18n:/i18n", } + // If no external static dir is provided, try to load from the working dir. + if staticDir == "" { + files = append(files, "static/email-templates", "static/public:/public") + } + fs, err = stuffbin.NewLocalFS("/", files...) if err != nil { lo.Fatalf("failed to initialize local file for assets: %v", err)