File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change 7
7
"log"
8
8
"os"
9
9
"path"
10
+ "regexp"
10
11
"strings"
11
12
"text/template"
12
13
@@ -80,6 +81,21 @@ func setLinksWithAppName(service *Service) {
80
81
}
81
82
}
82
83
84
+ func removeBlankLinkes (path string ) {
85
+ re := regexp .MustCompile (`(?m)^\s*\\\n` )
86
+ read , err := ioutil .ReadFile (path )
87
+ if err != nil {
88
+ panic (err )
89
+ }
90
+
91
+ newContents := re .ReplaceAllString (string (read ), "" )
92
+
93
+ err = ioutil .WriteFile (path , []byte (newContents ), 0 )
94
+ if err != nil {
95
+ panic (err )
96
+ }
97
+ }
98
+
83
99
func buildScriptDataTemplate (serviceName string , service Service ) ScriptDataTemplate {
84
100
// common data template for all services from the same app
85
101
data := ScriptDataTemplate {AppName : appName }
@@ -105,10 +121,13 @@ func saveToBash(services map[string]Service) (err error) {
105
121
106
122
for name , service := range services {
107
123
data := buildScriptDataTemplate (name , service )
124
+ fileName := path .Join (outputPath , data .Service .Name + ".1.sh" )
108
125
109
- f , _ := os .Create (path . Join ( outputPath , data . Service . Name + ".1.sh" ) )
126
+ f , _ := os .Create (fileName )
110
127
defer f .Close ()
111
128
t .Execute (f , data )
129
+
130
+ removeBlankLinkes (fileName )
112
131
}
113
132
114
133
return nil
You can’t perform that action at this time.
0 commit comments