fast and minimal static site generator
ssg

Move util to fileutil

anirudh.fi a64168ba 39b17ddd

verified
+22 -29
+19 -3
commands/build.go
··· 3 3 import ( 4 4 "fmt" 5 5 "os" 6 + "os/exec" 6 7 "path/filepath" 7 8 "sort" 8 9 "strings" ··· 10 11 11 12 "tangled.sh/icyphox.sh/vite/atom" 12 13 "tangled.sh/icyphox.sh/vite/config" 14 + util "tangled.sh/icyphox.sh/vite/fileutil" 13 15 "tangled.sh/icyphox.sh/vite/formats" 14 16 "tangled.sh/icyphox.sh/vite/formats/markdown" 15 17 "tangled.sh/icyphox.sh/vite/formats/yaml" 16 18 "tangled.sh/icyphox.sh/vite/types" 17 - "tangled.sh/icyphox.sh/vite/util" 18 19 ) 19 20 20 21 type Dir struct { ··· 224 225 return nil 225 226 } 226 227 228 + func runCmd(cmd string, args ...string) error { 229 + parts := strings.Fields(cmd) 230 + if len(parts) == 0 { 231 + return fmt.Errorf("error: is there an empty command?") 232 + } 233 + 234 + execCmd := exec.Command(parts[0], parts[1:]...) 235 + 236 + output, err := execCmd.CombinedOutput() 237 + if err != nil { 238 + return fmt.Errorf("error: command %q failed with %v: %s", cmd, err, output) 239 + } 240 + return nil 241 + } 242 + 227 243 func postBuild() error { 228 244 for _, cmd := range config.Config.PostBuild { 229 245 fmt.Println("vite: running post-build command:", cmd) 230 - if err := util.RunCmd(cmd); err != nil { 246 + if err := runCmd(cmd); err != nil { 231 247 return err 232 248 } 233 249 } ··· 237 253 func preBuild() error { 238 254 for _, cmd := range config.Config.PreBuild { 239 255 fmt.Println("vite: running pre-build command:", cmd) 240 - if err := util.RunCmd(cmd); err != nil { 256 + if err := runCmd(cmd); err != nil { 241 257 return err 242 258 } 243 259 }
+1 -1
formats/anything.go
··· 3 3 import ( 4 4 "path/filepath" 5 5 6 - "tangled.sh/icyphox.sh/vite/util" 6 + util "tangled.sh/icyphox.sh/vite/fileutil" 7 7 ) 8 8 9 9 // Anything is a stub format for unrecognized files
+1 -1
util/copy.go fileutil/copy.go
··· 1 - package util 1 + package fileutil 2 2 3 3 import ( 4 4 "fmt"
+1 -1
util/rmall.go fileutil/rmall.go
··· 1 - package util 1 + package fileutil 2 2 3 3 import ( 4 4 "os"
-23
util/run.go
··· 1 - package util 2 - 3 - import ( 4 - "fmt" 5 - "os/exec" 6 - "strings" 7 - ) 8 - 9 - func RunCmd(cmd string, args ...string) error { 10 - // Split the command into the executable and its arguments 11 - parts := strings.Fields(cmd) 12 - if len(parts) == 0 { 13 - return fmt.Errorf("error: is there an empty command?") 14 - } 15 - 16 - execCmd := exec.Command(parts[0], parts[1:]...) 17 - 18 - output, err := execCmd.CombinedOutput() 19 - if err != nil { 20 - return fmt.Errorf("error: command %q failed with %v: %s", cmd, err, output) 21 - } 22 - return nil 23 - }