minor reorg; deplopy progress
This commit is contained in:
parent
7a503b2b52
commit
18ab96ac84
|
@ -1,2 +1,3 @@
|
||||||
.*.swp
|
.*.swp
|
||||||
/warren
|
/warren
|
||||||
|
/deploy
|
||||||
|
|
|
@ -2,7 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/dballard/warren/src/warren"
|
"github.com/dballard/warren/lib/warren"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
|
@ -2,8 +2,9 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/dballard/warren/src/warren"
|
"github.com/dballard/warren/lib/warren"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
)
|
)
|
||||||
|
|
||||||
var deployUsage = `
|
var deployUsage = `
|
||||||
|
@ -18,13 +19,19 @@ var deployCmd = &Command{
|
||||||
Run: deployRun,
|
Run: deployRun,
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkDeployDir() {
|
func checkDeployDir() string {
|
||||||
_, err := os.Stat("deploy")
|
_, err := os.Stat("deploy")
|
||||||
if err != nil {
|
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 {
|
func getDeployFilesList() []string {
|
||||||
|
@ -32,14 +39,21 @@ func getDeployFilesList() []string {
|
||||||
return []string{name}
|
return []string{name}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func cp(dst, src string) error {
|
||||||
|
return exec.Command("cp", src, dst, "-r").Run()
|
||||||
|
}
|
||||||
|
|
||||||
func deployRun(cmd *Command, args ...string) {
|
func deployRun(cmd *Command, args ...string) {
|
||||||
if len(args) > 0 && args[0] == "help" {
|
if len(args) > 0 && args[0] == "help" {
|
||||||
fmt.Print(cmd.Help)
|
fmt.Print(cmd.Help)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
dst := checkDeployDir()
|
||||||
checkDeployDir()
|
fmt.Println(dst)
|
||||||
files := getDeployFilesList()
|
files := getDeployFilesList()
|
||||||
|
|
||||||
fmt.Println(files)
|
fmt.Println(files)
|
||||||
|
for _, file := range files {
|
||||||
|
cp(dst+file, file)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue