mirror of
https://github.com/facundoolano/jorge.git
synced 2024-11-16 07:47:40 +01:00
support passing a different root dir
This commit is contained in:
parent
e5917dc21e
commit
513befe8b8
2 changed files with 13 additions and 5 deletions
|
@ -2,6 +2,7 @@ package commands
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/facundoolano/blorg/site"
|
||||
)
|
||||
|
@ -30,12 +31,15 @@ func New() error {
|
|||
}
|
||||
|
||||
// Read the files in src/ render them and copy the result to target/
|
||||
// TODO add root dir override support
|
||||
func Build() error {
|
||||
site, err := site.Load(SRC_DIR, LAYOUTS_DIR)
|
||||
func Build(root string) error {
|
||||
src := filepath.Join(root, SRC_DIR)
|
||||
target := filepath.Join(root, TARGET_DIR)
|
||||
layouts := filepath.Join(root, LAYOUTS_DIR)
|
||||
|
||||
site, err := site.Load(src, layouts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return site.Build(SRC_DIR, TARGET_DIR, true, false)
|
||||
return site.Build(src, target, true, false)
|
||||
}
|
||||
|
|
6
main.go
6
main.go
|
@ -34,7 +34,11 @@ func run(args []string) error {
|
|||
initCmd.Parse(os.Args[2:])
|
||||
return commands.Init()
|
||||
case "build":
|
||||
return commands.Build()
|
||||
rootDir := "."
|
||||
if len(os.Args) > 2 {
|
||||
rootDir = os.Args[2]
|
||||
}
|
||||
return commands.Build(rootDir)
|
||||
case "new":
|
||||
newCmd.Parse(os.Args[2:])
|
||||
return commands.New()
|
||||
|
|
Loading…
Reference in a new issue