mark2web/assets.go

30 lines
752 B
Go
Raw Normal View History

2019-03-18 13:34:52 +01:00
package mark2web
2019-02-28 12:13:28 +01:00
import (
"strings"
"gitbase.de/apairon/mark2web/config"
2019-03-18 13:34:52 +01:00
"gitbase.de/apairon/mark2web/helper"
2019-02-28 12:13:28 +01:00
cpy "github.com/otiai10/copy"
)
2019-02-28 15:13:59 +01:00
// ProcessAssets copies the assets from input to output dir
2019-02-28 12:13:28 +01:00
func ProcessAssets() {
switch config.Config.Assets.Action {
case "copy":
from := config.Config.Assets.FromPath
to := config.Config.Assets.ToPath
if !strings.HasPrefix(from, "/") {
from = config.Config.Directories.Input + "/" + from
}
if !strings.HasPrefix(to, "/") {
to = config.Config.Directories.Output + "/" + to
}
2019-03-18 13:34:52 +01:00
helper.Log.Noticef("copying assets from '%s' to '%s'", from, to)
2019-02-28 12:13:28 +01:00
err := cpy.Copy(from, to)
if err != nil {
2019-03-18 13:34:52 +01:00
helper.Log.Panicf("could not copy assets from '%s' to '%s': %s", from, to, err)
2019-02-28 12:13:28 +01:00
}
}
}