File tree 1 file changed +12
-1
lines changed
1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package main
3
3
import (
4
4
"encoding/json"
5
5
"fmt"
6
+ "io/ioutil"
6
7
"log"
7
8
"os"
8
9
"os/exec"
@@ -50,12 +51,22 @@ func regenerate(dir string) error {
50
51
return nil
51
52
}
52
53
54
+ var expectFailure bool
55
+ if _ , err := os .Stat (filepath .Join (cwd , "stderr.txt" )); ! os .IsNotExist (err ) {
56
+ expectFailure = true
57
+ }
58
+
53
59
cmd := exec .Command ("sqlc-dev" , "generate" , "--experimental" )
54
60
cmd .Dir = cwd
55
61
out , failed := cmd .CombinedOutput ()
56
- if _ , err := os . Stat ( filepath . Join ( cwd , "stderr.txt" )); os . IsNotExist ( err ) && failed != nil {
62
+ if failed != nil && ! expectFailure {
57
63
return fmt .Errorf ("%s: sqlc-dev generate failed\n %s" , cwd , out )
58
64
}
65
+ if expectFailure {
66
+ if err := ioutil .WriteFile (filepath .Join (cwd , "stderr.txt" ), out , 0644 ); err != nil {
67
+ return fmt .Errorf ("failed to update stderr.txt: %v" , err )
68
+ }
69
+ }
59
70
}
60
71
return nil
61
72
})
You can’t perform that action at this time.
0 commit comments