Skip to content
This repository was archived by the owner on Nov 18, 2021. It is now read-only.

Commit 4476060

Browse files
committed
cmd/cue/cmd: load import dependencies of tool files
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>
1 parent c24a281 commit 4476060

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

cmd/cue/cmd/common.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,15 @@ func buildTools(cmd *Command, tags, args []string) (*cue.Instance, error) {
615615
inst = cue.Merge(insts...)
616616
}
617617

618+
r := internal.GetRuntime(inst).(*cue.Runtime)
619+
for _, b := range binst {
620+
for _, i := range b.Imports {
621+
if _, err := r.Build(i); err != nil {
622+
return nil, err
623+
}
624+
}
625+
}
626+
618627
inst = inst.Build(ti)
619628
return inst, inst.Err
620629
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
cue cmd foo
2+
cmp stdout cue_cmd_foo_both.golden
3+
4+
-- cue.mod/module.cue --
5+
module: "example.org/test"
6+
-- sub/sub.cue --
7+
package sub
8+
9+
User: "sub"
10+
-- x_tool.cue --
11+
package x
12+
13+
import (
14+
"tool/cli"
15+
16+
"example.org/test/sub"
17+
)
18+
19+
command: foo: cli.Print & {
20+
text: "test \(sub.User)"
21+
}
22+
-- cue_eval.golden --
23+
x: "sub"
24+
-- cue_cmd_foo_both.golden --
25+
test sub

0 commit comments

Comments
 (0)