mirror of https://github.com/Xhofe/alist
fix(ci): sort lang json file
parent
dc8d5106f9
commit
bc6baf1be0
|
@ -8,6 +8,7 @@ on:
|
||||||
- 'drivers/**'
|
- 'drivers/**'
|
||||||
- 'internal/bootstrap/data/setting.go'
|
- 'internal/bootstrap/data/setting.go'
|
||||||
- 'internal/conf/const.go'
|
- 'internal/conf/const.go'
|
||||||
|
- 'cmd/lang.go'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
@ -43,14 +44,7 @@ jobs:
|
||||||
cd alist
|
cd alist
|
||||||
go run ./main.go lang
|
go run ./main.go lang
|
||||||
cd ..
|
cd ..
|
||||||
- name: Format lang file
|
|
||||||
run: |
|
|
||||||
for file in ./alist/lang/*.json
|
|
||||||
do
|
|
||||||
cp -f "$file" "$file.old" || :
|
|
||||||
jq --sort-keys . "$file.old" > "$file" || :
|
|
||||||
done
|
|
||||||
rm ./alist/lang/*.json.old
|
|
||||||
- name: Copy lang file
|
- name: Copy lang file
|
||||||
run: |
|
run: |
|
||||||
cp -f ./alist/lang/*.json ./alist-web/src/lang/en/ 2>/dev/null || :
|
cp -f ./alist/lang/*.json ./alist-web/src/lang/en/ 2>/dev/null || :
|
||||||
|
|
|
@ -71,7 +71,7 @@ func writeFile(name string, data interface{}) {
|
||||||
} else {
|
} else {
|
||||||
log.Infof("%s.json changed, update file", name)
|
log.Infof("%s.json changed, update file", name)
|
||||||
//log.Infof("old: %+v\nnew:%+v", oldData, data)
|
//log.Infof("old: %+v\nnew:%+v", oldData, data)
|
||||||
utils.WriteJsonToFile(fmt.Sprintf("lang/%s.json", name), data)
|
utils.WriteJsonToFile(fmt.Sprintf("lang/%s.json", name), newData, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
stdjson "encoding/json"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
json "github.com/json-iterator/go"
|
json "github.com/json-iterator/go"
|
||||||
|
@ -10,8 +11,11 @@ import (
|
||||||
var Json = json.ConfigCompatibleWithStandardLibrary
|
var Json = json.ConfigCompatibleWithStandardLibrary
|
||||||
|
|
||||||
// WriteJsonToFile write struct to json file
|
// WriteJsonToFile write struct to json file
|
||||||
func WriteJsonToFile(dst string, data interface{}) bool {
|
func WriteJsonToFile(dst string, data interface{}, std ...bool) bool {
|
||||||
str, err := json.MarshalIndent(data, "", " ")
|
str, err := json.MarshalIndent(data, "", " ")
|
||||||
|
if len(std) > 0 && std[0] {
|
||||||
|
str, err = stdjson.MarshalIndent(data, "", " ")
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("failed convert Conf to []byte:%s", err.Error())
|
log.Errorf("failed convert Conf to []byte:%s", err.Error())
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Reference in New Issue