Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ae4ed01

Browse files
committed
🎨 Fix b3log#221
1 parent ccd3443 commit ae4ed01

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

main.go

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -104,21 +104,23 @@ func handleSignal(server *http.Server) {
104104

105105
func replaceServerConf() {
106106
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+
}
118120
}
119121

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 {
122124
if strings.HasSuffix(path, ".tpl") {
123125
data, err := ioutil.ReadFile(path)
124126
if nil != err {

pipe.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"Server": "http://localhost:5897",
33
"StaticServer": "",
4-
"StaticResourceVersion": "1553763575798",
4+
"StaticResourceVersion": "1553774945297",
55
"RuntimeMode": "dev",
66
"LogLevel": "debug",
77
"ShowSQL": false,

theme/sw.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)