From cf9e6f260d9df12f6c23e1f9c52d212180538413 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Sat, 28 Sep 2019 14:52:31 +0800 Subject: [PATCH] chore: debug command --- plugin.go | 10 ++++++++-- plugin_test.go | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/plugin.go b/plugin.go index 7493aee..db95fff 100644 --- a/plugin.go +++ b/plugin.go @@ -202,14 +202,17 @@ func (p *Plugin) Args(target string) []string { p.Config.TarExec, "-xf", p.DestFile, - "-C", - target, ) if p.Config.StripComponents > 0 { args = append(args, fmt.Sprintf("-strip-components=%d", p.Config.StripComponents)) } + args = append(args, + "-C", + target, + ) + return args } @@ -318,6 +321,9 @@ func (p *Plugin) Exec() error { // untar file p.log(host, "untar file", p.DestFile) commamd := strings.Join(p.Args(target), " ") + if p.Config.Debug { + fmt.Println("$", commamd) + } _, _, _, err = ssh.Run(commamd, p.Config.CommandTimeout) if err != nil { diff --git a/plugin_test.go b/plugin_test.go index 24604c0..846014d 100644 --- a/plugin_test.go +++ b/plugin_test.go @@ -267,6 +267,7 @@ func TestIgnoreList(t *testing.T) { Target: []string{filepath.Join(u.HomeDir, "ignore")}, CommandTimeout: 60 * time.Second, TarExec: "tar", + Debug: true, }, }