@@ -104,21 +104,23 @@ func handleSignal(server *http.Server) {
104
104
105
105
func replaceServerConf () {
106
106
path := "theme/sw.min.js.tpl"
107
- data , err := ioutil .ReadFile (path )
108
- if nil != err {
109
- logger .Fatal ("read file [" + path + "] failed: " + err .Error ())
110
- }
111
- content := string (data )
112
- content = strings .Replace (content , "http://server.tpl.json" , model .Conf .Server , - 1 )
113
- content = strings .Replace (content , "http://staticserver.tpl.json" , model .Conf .StaticServer , - 1 )
114
- content = strings .Replace (content , "${StaticResourceVersion}" , model .Conf .StaticResourceVersion , - 1 )
115
- writePath := strings .TrimSuffix (path , ".tpl" )
116
- if err = ioutil .WriteFile (writePath , []byte (content ), 0644 ); nil != err {
117
- logger .Fatal ("replace sw.min.js in [" + path + "] failed: " + err .Error ())
107
+ if util .File .IsExist (path ) {
108
+ data , err := ioutil .ReadFile (path )
109
+ if nil != err {
110
+ logger .Fatal ("read file [" + path + "] failed: " + err .Error ())
111
+ }
112
+ content := string (data )
113
+ content = strings .Replace (content , "http://server.tpl.json" , model .Conf .Server , - 1 )
114
+ content = strings .Replace (content , "http://staticserver.tpl.json" , model .Conf .StaticServer , - 1 )
115
+ content = strings .Replace (content , "${StaticResourceVersion}" , model .Conf .StaticResourceVersion , - 1 )
116
+ writePath := strings .TrimSuffix (path , ".tpl" )
117
+ if err = ioutil .WriteFile (writePath , []byte (content ), 0644 ); nil != err {
118
+ logger .Fatal ("replace sw.min.js in [" + path + "] failed: " + err .Error ())
119
+ }
118
120
}
119
121
120
- if util .File .IsExist ("console/dist/" ) { // not exist if npm run dev
121
- err = filepath .Walk ("console/dist/" , func (path string , f os.FileInfo , err error ) error {
122
+ if util .File .IsExist ("console/dist/" ) {
123
+ err : = filepath .Walk ("console/dist/" , func (path string , f os.FileInfo , err error ) error {
122
124
if strings .HasSuffix (path , ".tpl" ) {
123
125
data , err := ioutil .ReadFile (path )
124
126
if nil != err {
0 commit comments