minor reorg; deplopy progress
This commit is contained in:
parent
7a503b2b52
commit
18ab96ac84
|
@ -1,2 +1,3 @@
|
|||
.*.swp
|
||||
/warren
|
||||
/deploy
|
||||
|
|
|
@ -2,7 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/dballard/warren/src/warren"
|
||||
"github.com/dballard/warren/lib/warren"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue