@@ -11,7 +11,13 @@ import (
11
11
12
12
// runs openapi-generator-cli with args passed.
13
13
func runOpenAPIGenerator (args ... string ) error {
14
- output , err := exec .Command ("openapi-generator-cli" , args ... ).Output ()
14
+ path , err := exec .LookPath ("openapi-generator-cli" )
15
+ if err != nil {
16
+ log .Debugf ("err : %s" , err )
17
+ return errors .New ("'openapi-generator-cli' command doesn't exist" )
18
+ }
19
+ log .Debugf ("openapi-generator-cli is available at %s" , path )
20
+ output , err := exec .Command (path , args ... ).Output ()
15
21
if err != nil {
16
22
log .Debugf ("Output : %s" , string (output ))
17
23
log .Debugf ("err : %s" , err )
@@ -46,6 +52,12 @@ func ProcessOpenAPITemplate(ctx context.Context) error {
46
52
return err
47
53
}
48
54
55
+ // dos2unix on the file
56
+ if err = runDos2Unix (fileName ); err != nil {
57
+ log .Debugf ("err : %s" , err )
58
+ return err
59
+ }
60
+
49
61
// generate code by openapi.yaml
50
62
if err0 := runOpenAPIGenerator ("generate" , "-i" , fileName , "-g" , strings .ToLower (values .LanguageNode .RestConfig .Framework ), "-o" , values .NodeDirectoryName , "--git-user-id" , values .TemplateVars [UserName ], "--git-repo-id" , values .TemplateVars [RepositoryName ]+ "/" + values .LanguageNode .Name ); err0 != nil {
51
63
log .Debugf ("err : %s" , err0 )
@@ -59,3 +71,20 @@ func ProcessOpenAPITemplate(ctx context.Context) error {
59
71
}
60
72
return nil
61
73
}
74
+
75
+ func runDos2Unix (fileName string ) error {
76
+ path , err := exec .LookPath ("dos2unix" )
77
+ if err != nil {
78
+ log .Debugf ("err : %s" , err )
79
+ return errors .New ("'dos2unix' command doesn't exist" )
80
+ }
81
+ log .Debugf ("dos2unix is available at %s" , path )
82
+ args := []string {fileName }
83
+ output , err := exec .Command (path , args ... ).Output ()
84
+ log .Debugf ("Output : %s" , string (output ))
85
+ if err != nil {
86
+ log .Debugf ("err : %s" , err )
87
+ return err
88
+ }
89
+ return nil
90
+ }
0 commit comments