Skip to content

Commit

Permalink
Read config for build command.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimafisk committed Oct 5, 2019
1 parent fbd15de commit f3ba072
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ package cmd
import (
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
"plenti/readers"
"strings"

"github.com/spf13/cobra"
Expand All @@ -33,11 +35,17 @@ var buildCmd = &cobra.Command{
of your choosing. The files that are created are all
you need to deploy for your website.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("build called")

// TODO: use SiteConfig struct
newpath := filepath.Join(".", "public")
os.MkdirAll(newpath, os.ModePerm)
// Create build directory based on config file.
siteConfig := readers.GetSiteConfig()
newpath := filepath.Join(".", siteConfig.BuildDir)
err := os.MkdirAll(newpath, os.ModePerm)
if err != nil {
fmt.Printf("Unable to create \"%v\" build directory\n", siteConfig.BuildDir)
log.Fatal(err)
} else {
fmt.Printf("Creating \"%v\" build directory\n", siteConfig.BuildDir)
}

// TODO: replace hardcoded scaffolding
var publicHTML = map[string][]byte{
Expand Down

0 comments on commit f3ba072

Please sign in to comment.