mirror of
https://github.com/rwinkhart/glamour-temp-MUTN.git
synced 2026-10-28 20:18:16 -04:00
Read default styles before reading from the file system (#73)
This commit is contained in:
1 parent
28b4a5ca52
commit
1246d13c16
1 file changed
+7
-10
+7
-10
@@ -135,20 +135,17 @@ func WithEnvironmentConfig() TermRendererOption {
|
|||||||
// standard style.
|
// standard style.
|
||||||
func WithStylePath(stylePath string) TermRendererOption {
|
func WithStylePath(stylePath string) TermRendererOption {
|
||||||
return func(tr *TermRenderer) error {
|
return func(tr *TermRenderer) error {
|
||||||
jsonBytes, err := ioutil.ReadFile(stylePath)
|
styles, err := getDefaultStyle(stylePath)
|
||||||
switch {
|
if err != nil {
|
||||||
case err == nil:
|
jsonBytes, err := ioutil.ReadFile(stylePath)
|
||||||
return json.Unmarshal(jsonBytes, &tr.ansiOptions.Styles)
|
|
||||||
case os.IsNotExist(err):
|
|
||||||
styles, err := getDefaultStyle(stylePath)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
tr.ansiOptions.Styles = *styles
|
|
||||||
return nil
|
return json.Unmarshal(jsonBytes, &tr.ansiOptions.Styles)
|
||||||
default:
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
tr.ansiOptions.Styles = *styles
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user