Skip to content

Commit

Permalink
cue/load: move no-package-args logic
Browse files Browse the repository at this point in the history
This is a small change to move the "no arguments means the
current package" logic earlier in the `Instances` function
so that we can expand the arguments before creating
the loader.

Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: I1d300699ddee5823501baa9ef82b4f54018e8d1a
  • Loading branch information
rogpeppe committed May 24, 2024
1 parent 3f0d7be commit 456288c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
5 changes: 4 additions & 1 deletion cue/load/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ func Instances(args []string, c *Config) []*build.Instance {
return []*build.Instance{c.newErrInstance(err)}
}
c = newC
if len(args) == 0 {
args = []string{"."}
}

// TODO: This requires packages to be placed before files. At some point this
// could be relaxed.
Expand Down Expand Up @@ -95,7 +98,7 @@ func Instances(args []string, c *Config) []*build.Instance {
}

a := []*build.Instance{}
if len(args) == 0 || i > 0 {
if len(pkgArgs) > 0 {
for _, m := range l.importPaths(pkgArgs) {
if m.Err != nil {
inst := c.newErrInstance(m.Err)
Expand Down
3 changes: 0 additions & 3 deletions cue/load/loader_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,9 +460,6 @@ func warnUnmatched(matches []*match) {
// command line. It canonicalizes the patterns but does not
// evaluate any matches.
func cleanPatterns(patterns []string) []string {
if len(patterns) == 0 {
return []string{"."}
}
var out []string
for _, a := range patterns {
// Arguments are supposed to be import paths, but
Expand Down

0 comments on commit 456288c

Please sign in to comment.