Skip to content

Commit

Permalink
cmd/cue/cmd: load import dependencies of tool files
Browse files Browse the repository at this point in the history
Fixes #869
Fixes #871

Change-Id: I7c439d298d819bfc20c33f2e028a0216a57c4307
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/9303
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Paul Jolly <paul@myitcv.org.uk>
  • Loading branch information
mpvl committed Apr 2, 2021
1 parent c24a281 commit 4476060
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmd/cue/cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,15 @@ func buildTools(cmd *Command, tags, args []string) (*cue.Instance, error) {
inst = cue.Merge(insts...)
}

r := internal.GetRuntime(inst).(*cue.Runtime)
for _, b := range binst {
for _, i := range b.Imports {
if _, err := r.Build(i); err != nil {
return nil, err
}
}
}

inst = inst.Build(ti)
return inst, inst.Err
}
Expand Down
25 changes: 25 additions & 0 deletions cmd/cue/cmd/testdata/script/cmd_deppkg.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
cue cmd foo
cmp stdout cue_cmd_foo_both.golden

-- cue.mod/module.cue --
module: "example.org/test"
-- sub/sub.cue --
package sub

User: "sub"
-- x_tool.cue --
package x

import (
"tool/cli"

"example.org/test/sub"
)

command: foo: cli.Print & {
text: "test \(sub.User)"
}
-- cue_eval.golden --
x: "sub"
-- cue_cmd_foo_both.golden --
test sub

0 comments on commit 4476060

Please sign in to comment.