Skip to content

Commit

Permalink
fix(插件): 修复清理插件nil指针问题
Browse files Browse the repository at this point in the history
  • Loading branch information
storezhang committed Jan 22, 2024
1 parent 398f2c1 commit 33b14b1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
15 changes: 2 additions & 13 deletions internal/cleanup/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"os"

"github.com/dronestock/drone/internal/cleanup/internal/work"
"github.com/goexl/gex"
)

type Builder struct {
Expand Down Expand Up @@ -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() {
Expand Down
17 changes: 17 additions & 0 deletions internal/cleanup/command.go
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions internal/plugin/bootstrap_finally.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 33b14b1

Please sign in to comment.