File tree 2 files changed +17
-6
lines changed
2 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ func runFixAll(cmd *Command, args []string) error {
89
89
90
90
for _ , i := range instances {
91
91
for _ , f := range i .Files {
92
- if done [f ] || ! strings .HasSuffix (f .Filename , ".cue" ) {
92
+ if done [f ] || ( f . Filename != "-" && ! strings .HasSuffix (f .Filename , ".cue" ) ) {
93
93
continue
94
94
}
95
95
done [f ] = true
@@ -99,9 +99,14 @@ func runFixAll(cmd *Command, args []string) error {
99
99
errs = errors .Append (errs , errors .Promote (err , "format" ))
100
100
}
101
101
102
- err = os .WriteFile (f .Filename , b , 0644 )
103
- if err != nil {
104
- errs = errors .Append (errs , errors .Promote (err , "write" ))
102
+ if f .Filename == "-" {
103
+ if _ , err := cmd .OutOrStdout ().Write (b ); err != nil {
104
+ return err
105
+ }
106
+ } else {
107
+ if err := os .WriteFile (f .Filename , b , 0644 ); err != nil {
108
+ errs = errors .Append (errs , errors .Promote (err , "write" ))
109
+ }
105
110
}
106
111
}
107
112
}
Original file line number Diff line number Diff line change 1
- exec cue fix ./...
1
+ # Just like other commands, we can fix with stdin/stdout.
2
+ stdin p/three.cue
3
+ exec cue fix -
4
+ cmp stdout p/three.cue.fixed
5
+
2
6
# Make sure we fix all files in a directory, even if they're a mix of packages (or no packages).
7
+ exec cue fix ./...
3
8
cmp p/one.cue p/one.cue.fixed
4
9
cmp p/two.cue p/two.cue.fixed
5
10
cmp p/three.cue p/three.cue.fixed
11
+
6
12
-- p/one.cue --
7
13
package one
8
14
@@ -28,4 +34,4 @@ out: list.Repeat(["baz"], 3)
28
34
-- p/three.cue.fixed --
29
35
import "list"
30
36
31
- out: list.Concat([["a"], (list.Concat([(list.Repeat(["a"], 7)), ["gh"]]))])
37
+ out: list.Concat([["a"], (list.Concat([(list.Repeat(["a"], 7)), ["gh"]]))])
You can’t perform that action at this time.
0 commit comments