Skip to content

Commit

Permalink
feat: shlex to quote aware split dependencies (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
joerdav authored Aug 22, 2023
1 parent c87eea6 commit 3244411
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/joerdav/xc
go 1.20

require (
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
github.com/posener/complete/v2 v2.0.1-alpha.13
mvdan.cc/sh/v3 v3.6.0
)
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
Expand Down
4 changes: 3 additions & 1 deletion run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"path/filepath"
"strings"

"github.com/google/shlex"
"github.com/joerdav/xc/models"
)

Expand Down Expand Up @@ -112,7 +113,7 @@ func (r *Runner) Run(ctx context.Context, name string, inputs []string) error {
return err
}
for _, t := range task.DependsOn {
ta := strings.Fields(t)
ta, _ := shlex.Split(t)
err := r.Run(ctx, ta[0], ta[1:])
if err != nil {
return err
Expand Down Expand Up @@ -152,6 +153,7 @@ func (r *Runner) ValidateDependencies(task string, prevTasks []string) error {
return fmt.Errorf("task %s has a parsing error: %s", task, t.ParsingError)
}
for _, t := range t.DependsOn {
t, _, _ := strings.Cut(t, " ")
st, ok := r.tasks.Get(t)
if !ok {
return fmt.Errorf("task %s not found", t)
Expand Down

0 comments on commit 3244411

Please sign in to comment.