Skip to content

Commit b011557

Browse files
Dennis BergevinDennis Bergevin
authored andcommitted
update error handling and config loading
1 parent 260e1ef commit b011557

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func runPlaywrightList(projects multiFlag, onlyChanged, lastFailed bool, config
5151
fmt.Println("Running command:", "npx", strings.Join(args, " "))
5252
var out bytes.Buffer
5353
cmd.Stdout = &out
54-
cmd.Stderr = os.Stderr
54+
cmd.Stderr = nil
5555

5656
var parsed PlaywrightOutput
5757
if err := cmd.Run(); err != nil {

styles.go

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,23 @@ func defaultStyles() map[string]lipgloss.Style {
6262
}
6363

6464
func loadStyleConfig() (map[string]lipgloss.Style, DisplayOptions, DisplayEmojis) {
65+
homeDir, err := os.UserHomeDir()
66+
if err != nil {
67+
fmt.Fprintf(os.Stderr, "Error getting user home directory: %v\n", err)
68+
// Fallback: just try current dir config only
69+
paths := []string{"./.pwtree.json"}
70+
return determineStyleConfig(paths)
71+
}
72+
6573
paths := []string{
6674
"./.pwtree.json",
67-
filepath.Join(os.Getenv("HOME"), ".config", "pwtree", "config.json"),
75+
filepath.Join(homeDir, ".config", "pwtree", "config.json"),
6876
}
6977

78+
return determineStyleConfig(paths)
79+
}
80+
81+
func determineStyleConfig(paths []string) (map[string]lipgloss.Style, DisplayOptions, DisplayEmojis) {
7082
var configData []byte
7183
for _, path := range paths {
7284
if data, err := os.ReadFile(path); err == nil {
@@ -120,9 +132,9 @@ func loadStyleConfig() (map[string]lipgloss.Style, DisplayOptions, DisplayEmojis
120132
}
121133

122134
emojis := DisplayEmojis{
123-
Root: defaultEmojis.Root,
124-
File: defaultEmojis.File,
125-
Suite: defaultEmojis.Suite,
135+
Root: "",
136+
File: "",
137+
Suite: "",
126138
}
127139

128140
if cfg.EmojiOverrides.Root != nil {
@@ -135,9 +147,11 @@ func loadStyleConfig() (map[string]lipgloss.Style, DisplayOptions, DisplayEmojis
135147
emojis.Suite = *cfg.EmojiOverrides.Suite
136148
}
137149

138-
return styles, DisplayOptions{
150+
display := DisplayOptions{
139151
ShowProjects: cfg.ShowProjects == nil || *cfg.ShowProjects,
140152
ShowTags: cfg.ShowTags == nil || *cfg.ShowTags,
141153
ShowFileLines: cfg.ShowFileLines == nil || *cfg.ShowFileLines,
142-
}, emojis
154+
}
155+
156+
return styles, display, emojis
143157
}

0 commit comments

Comments
 (0)