Skip to content

Commit

Permalink
cmd/fix: allow fix to load all packages in a directory
Browse files Browse the repository at this point in the history
Unlike `cue eval`, `cue fix` should load and operate on all cue files in
a directory, regardless of whether they belong to the same package or
not.

Fixes #3405

Signed-off-by: Matthew Sackman <matthew@cue.works>
Change-Id: If79c6d019b9496cfefc833d3fa5e5b6a98ae0ade
Dispatch-Trailer: {"type":"trybot","CL":1200351,"patchset":1,"ref":"refs/changes/51/1200351/1","targetBranch":"master"}
  • Loading branch information
cuematthew authored and cueckoo committed Aug 30, 2024
1 parent 9956f16 commit 24fe8c2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cmd/cue/cmd/fix.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ func runFixAll(cmd *Command, args []string) error {
}

instances := load.Instances(args, &load.Config{
Tests: true,
Tools: true,
Tests: true,
Tools: true,
Package: "*",
})

errs := fix.Instances(instances, opts...)
Expand Down
17 changes: 17 additions & 0 deletions cmd/cue/cmd/testdata/script/fix.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
exec cue fix ./...
cmp good/good.cue good/good.cue.fixed

-- good/good.cue --
package good

out: ["foo"] + ["bar"]
-- good/good.cue.fixed --
package good

import list6c6973 "list"

out: list6c6973.Concat([["foo"], ["bar"]])
-- bad/bad1.cue --
package bad1
-- bad/bad2.cue --
package bad2

0 comments on commit 24fe8c2

Please sign in to comment.