add cacheDir flag (#11)

golang version of #7 

-----
This enables setting a custom cache directory for Hugo. Some caching
plugins (e.g. http://plugins.drone.io/drillster/drone-volume-cache/)
require the directories to be cached to be located inside the workspace.
This commit is contained in:
techknowlogick 2018-10-29 03:45:36 -04:00 committed by Bo-Yi Wu
parent fc5eb448c3
commit 9aee76b213
3 changed files with 11 additions and 0 deletions

View File

@ -26,6 +26,7 @@ docker run --rm \
-e PLUGIN_BUILDDRAFTS=false \ -e PLUGIN_BUILDDRAFTS=false \
-e PLUGIN_BUILDEXPIRED=false \ -e PLUGIN_BUILDEXPIRED=false \
-e PLUGIN_BUILDFUTURE=false \ -e PLUGIN_BUILDFUTURE=false \
-e PLUGIN_CACHEDIR=false \
-e PLUGIN_CONFIG=false \ -e PLUGIN_CONFIG=false \
-e PLUGIN_CONTENT=false \ -e PLUGIN_CONTENT=false \
-e PLUGIN_LAYOUT=false \ -e PLUGIN_LAYOUT=false \

View File

@ -36,6 +36,12 @@ func main() {
Usage: "include content with publishdate in the future", Usage: "include content with publishdate in the future",
EnvVar: "PLUGIN_BUILDFUTURE", EnvVar: "PLUGIN_BUILDFUTURE",
}, },
cli.StringFlag{
Name: "cacheDir",
Usage: "change cache directory (useful when using caching plugins)",
EnvVar: "PLUGIN_CACHEDIR",
Value: "",
},
cli.StringFlag{ cli.StringFlag{
Name: "config", Name: "config",
Usage: "config file (default is path/config.yaml|json|toml)", Usage: "config file (default is path/config.yaml|json|toml)",

View File

@ -18,6 +18,7 @@ type (
BuildDrafts bool BuildDrafts bool
BuildExpired bool BuildExpired bool
BuildFuture bool BuildFuture bool
CacheDir string
Config string Config string
Content string Content string
Layout string Layout string
@ -75,6 +76,9 @@ func commandBuild(config Config) *exec.Cmd {
args = append(args, "-F") args = append(args, "-F")
} }
// add string args // add string args
if config.CacheDir != "" {
args = append(args, "--cacheDir", config.CacheDir)
}
if config.Config != "" { if config.Config != "" {
args = append(args, "--config", config.Config) args = append(args, "--config", config.Config)
} }