diff --git a/internal/cleanup/builder.go b/internal/cleanup/builder.go index 32c7d4f..32c696d 100644 --- a/internal/cleanup/builder.go +++ b/internal/cleanup/builder.go @@ -5,7 +5,6 @@ import ( "os" "github.com/dronestock/drone/internal/cleanup/internal/work" - "github.com/goexl/gex" ) type Builder struct { @@ -48,18 +47,8 @@ func (b *Builder) Write(filename string, data []byte, mode os.FileMode) *Builder return b } -func (b *Builder) Command(command string) (builder *Command) { - builder = new(Command) - builder.gex = gex.New(command) - builder.gex.Context(b.ctx) - if nil == b.pwe || *b.pwe { - builder.gex.Pwe() - } - if b.verbose { - builder.gex.Echo() - } - - return +func (b *Builder) Command(name string) *Command { + return NewCommand(b.ctx, b, b.pwe, b.verbose, name) } func (b *Builder) Build() { diff --git a/internal/cleanup/command.go b/internal/cleanup/command.go index cf1a05c..109218c 100644 --- a/internal/cleanup/command.go +++ b/internal/cleanup/command.go @@ -1,6 +1,8 @@ package cleanup import ( + "context" + "github.com/dronestock/drone/internal/cleanup/internal/work" "github.com/goexl/gex" "github.com/goexl/gox/args" @@ -11,6 +13,21 @@ type Command struct { builder *Builder } +func NewCommand(ctx context.Context, builder *Builder, pwe *bool, verbose bool, name string) (command *Command) { + command = new(Command) + command.gex = gex.New(name) + command.builder = builder + command.gex.Context(ctx) + if nil == pwe || *pwe { + command.gex.Pwe() + } + if verbose { + command.gex.Echo() + } + + return +} + func (c *Command) Args(args *args.Args) (command *Command) { c.gex.Args(args) command = c diff --git a/internal/plugin/bootstrap_finally.go b/internal/plugin/bootstrap_finally.go index ee1c941..a536c21 100644 --- a/internal/plugin/bootstrap_finally.go +++ b/internal/plugin/bootstrap_finally.go @@ -14,6 +14,7 @@ import ( func (b *Bootstrap) finally(err *error) { if finally := recover(); nil != finally { + fmt.Println(finally) fmt.Println(b.stack()) os.Exit(internal.ExitCodeFailed) }