minor reorg; deplopy progress

This commit is contained in:
Dan Ballard 2014-12-12 23:54:02 -08:00
parent 7a503b2b52
commit 18ab96ac84
5 changed files with 23 additions and 8 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
.*.swp
/warren
/deploy

View File

@ -2,7 +2,7 @@ package main
import (
"fmt"
"github.com/dballard/warren/src/warren"
"github.com/dballard/warren/lib/warren"
"log"
"os"
"os/exec"

View File

@ -2,8 +2,9 @@ package main
import (
"fmt"
"github.com/dballard/warren/src/warren"
"github.com/dballard/warren/lib/warren"
"os"
"os/exec"
)
var deployUsage = `
@ -18,13 +19,19 @@ var deployCmd = &Command{
Run: deployRun,
}
func checkDeployDir() {
func checkDeployDir() string {
_, err := os.Stat("deploy")
if err != nil {
os.Mkdir("deploy", os.ModeDir)
os.Mkdir("deploy", os.ModeDir|0777)
}
// does ./deploy/DST exist?
// if not make
githash := warren.GitHash()
dst := "deploy/" + githash + "/"
_, err = os.Stat(dst)
if err != nil {
os.Mkdir(dst, os.ModeDir|0777)
}
return dst
}
func getDeployFilesList() []string {
@ -32,14 +39,21 @@ func getDeployFilesList() []string {
return []string{name}
}
func cp(dst, src string) error {
return exec.Command("cp", src, dst, "-r").Run()
}
func deployRun(cmd *Command, args ...string) {
if len(args) > 0 && args[0] == "help" {
fmt.Print(cmd.Help)
return
}
checkDeployDir()
dst := checkDeployDir()
fmt.Println(dst)
files := getDeployFilesList()
fmt.Println(files)
for _, file := range files {
cp(dst+file, file)
}
}

View File