Compare commits

...

2 Commits

Author SHA1 Message Date
Bo-Yi Wu 77dbb22aed test: support windows testing. (#21) 2017-01-03 16:59:00 +08:00
Bo-Yi Wu b69d758088 feat: support windows (#20) 2017-01-03 16:22:06 +08:00
5 changed files with 46 additions and 2 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ EXECUTABLE := drone-scp
DEPLOY_ACCOUNT := appleboy
DEPLOY_IMAGE := $(EXECUTABLE)
TARGETS ?= linux darwin
TARGETS ?= linux darwin windows
PACKAGES ?= $(shell go list ./... | grep -v /vendor/)
SOURCES ?= $(shell find . -name "*.go" -type f)
TAGS ?=
+7
View File
@@ -0,0 +1,7 @@
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
package main
func getRealPath(path string) string {
return path
}
+11
View File
@@ -0,0 +1,11 @@
// +build windows
package main
import (
"strings"
)
func getRealPath(path string) string {
return "/" + strings.Replace(strings.Replace(path, ":", "", -1), "\\", "/", -1)
}
+25
View File
@@ -0,0 +1,25 @@
package main
import "testing"
func TestGetRealPath(t *testing.T) {
type args struct {
path string
}
tests := []struct {
name string
args args
want string
}{
{
"Test Windows Path",
"C:\\Users\\appleboy\\test.txt",
"/C/Users/appleboy/test.txt"
}
}
for _, tt := range tests {
if got := getRealPath(tt.args.path); got != tt.want {
t.Errorf("%q. getRealPath() = %v, want %v", tt.name, got, tt.want)
}
}
}
+2 -1
View File
@@ -99,7 +99,8 @@ func (p Plugin) Exec() error {
// run archive command
log.Println("tar all files into " + tar)
args := append(append([]string{}, "-cf", tar), files...)
args := append(append([]string{}, "-cf", getRealPath(tar)), files...)
cmd := exec.Command("tar", args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr