Skip to content

fix: expand ~ in style path from glow.yml - #949

Open
c-tonneslan wants to merge 1 commit into
charmbracelet:masterfrom
c-tonneslan:fix/expand-tilde-in-style-config-path
Open

fix: expand ~ in style path from glow.yml#949
c-tonneslan wants to merge 1 commit into
charmbracelet:masterfrom
c-tonneslan:fix/expand-tilde-in-style-config-path

Conversation

@c-tonneslan

Copy link
Copy Markdown

Closes #713.

When style: in glow.yml starts with ~, glow fails to open it:

$ glow README.md
Error: open ~/.config/glow/sarastyle.json: no such file or directory

validateStyle did call utils.ExpandPath, but only on the function-local copy of the parameter, so the expanded value never made it back to the outer style package var. Glamour then tried to open the literal ~/... path.

Fix is to return the expanded path from validateStyle and use that at both call sites (the CLI flow in validateOptions, and the TUI flow in runTUI). Built-in style names like auto / dark / light are returned unchanged.

Added a TestValidateStyle covering the built-in pass-through, the ~-expansion happy path, and the error message when the file is missing (the message should show the expanded path, not the raw tilde).

The validateStyle function was expanding the tilde on a local copy of
the path but never returning the expanded value, so the outer style
variable kept the literal `~/...` form. Glamour then failed to open
the file at runtime with `no such file or directory`.

Return the expanded path from validateStyle and use it at both call
sites. Closes charmbracelet#713.

Signed-off-by: Charlie Tonneslan <cst0520@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v2.1.0 Does not resolve ~ to $HOME in configuration

1 participant