mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-03-05 20:49:04 -08:00
parent
61cb33f4f9
commit
f90840e3ec
|
@ -8,6 +8,8 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/gookit/config/v2"
|
"github.com/gookit/config/v2"
|
||||||
"github.com/gookit/config/v2/json"
|
"github.com/gookit/config/v2/json"
|
||||||
|
@ -127,7 +129,14 @@ func exportConfig(configFile, format string) string {
|
||||||
var prettyJSON bytes.Buffer
|
var prettyJSON bytes.Buffer
|
||||||
err := json2.Indent(&prettyJSON, buf.Bytes(), "", " ")
|
err := json2.Indent(&prettyJSON, buf.Bytes(), "", " ")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return prettyJSON.String()
|
unescapeUnicodeCharactersInJSON := func(rawJSON []byte) string {
|
||||||
|
str, err := strconv.Unquote(strings.ReplaceAll(strconv.Quote(string(rawJSON)), `\\u`, `\u`))
|
||||||
|
if err != nil {
|
||||||
|
return err.Error()
|
||||||
|
}
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
return unescapeUnicodeCharactersInJSON(prettyJSON.Bytes())
|
||||||
}
|
}
|
||||||
case config.Yaml:
|
case config.Yaml:
|
||||||
prefix := "# yaml-language-server: $schema=https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json\n\n"
|
prefix := "# yaml-language-server: $schema=https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json\n\n"
|
||||||
|
|
13
src/settings_test.go
Normal file
13
src/settings_test.go
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestSettingsExportJSON(t *testing.T) {
|
||||||
|
content := exportConfig("../themes/jandedobbeleer.omp.json", "json")
|
||||||
|
assert.NotContains(t, content, "\\u003ctransparent\\u003e")
|
||||||
|
assert.Contains(t, content, "<transparent>")
|
||||||
|
}
|
Loading…
Reference in a new issue