123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- package main
- import (
- "flag"
- "fmt"
- "os"
- "os/exec"
- "runtime"
- "strings"
- )
- var target = "../www/"
- func main() {
- fmt.Println("=============start==============")
- dir := flag.String("dir", "yyq_admin", "dir")
- flag.Parse()
- target += *dir + "/"
- fmt.Println("target_dir", target)
- os.RemoveAll(target + "static")
- os.Remove(target + "index.html")
- os.Remove(target + "favicon.ico")
- copyDir("./dist", target)
- }
- func FormatPath(s string) string {
- switch runtime.GOOS {
- case "windows":
- return strings.Replace(s, "/", "\\", -1)
- case "darwin", "linux":
- return strings.Replace(s, "\\", "/", -1)
- default:
- return s
- }
- }
- func copyDir(src string, dest string) {
- src = FormatPath(src)
- dest = FormatPath(dest)
- var cmd *exec.Cmd
- switch runtime.GOOS {
- case "windows":
- cmd = exec.Command("xcopy", src, dest, "/I", "/E")
- case "darwin", "linux":
- cmd = exec.Command("cp", "-R", src, dest)
- }
- outPut, e := cmd.Output()
- if e != nil {
- fmt.Println("copy error", e.Error())
- return
- }
- fmt.Println(string(outPut))
- }
|