mirror of
https://github.com/appleboy/drone-scp.git
synced 2026-06-16 14:49:20 +08:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 77dbb22aed | |||
| b69d758088 |
@@ -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 ?=
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
||||
|
||||
package main
|
||||
|
||||
func getRealPath(path string) string {
|
||||
return path
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// +build windows
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func getRealPath(path string) string {
|
||||
return "/" + strings.Replace(strings.Replace(path, ":", "", -1), "\\", "/", -1)
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user