Visitar URL original
Disable color in `prek cache dir` output by KSmanis · Pull Request #168 · j178/prek-action · GitHub
Skip to content

Disable color in prek cache dir output - #168

Merged
j178 merged 2 commits into
j178:mainfrom
KSmanis:agent/strip-ansi-cache-path
Jul 19, 2026
Merged

j178 merged 2 commits into
j178:mainfrom
KSmanis:agent/strip-ansi-cache-path

Conversation

@KSmanis

@KSmanis KSmanis commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Pass --color=never to prek cache dir so its machine-readable output remains a plain path even when PREK_COLOR=always is set.

This prevents ANSI escape sequences from reaching @actions/cache, where they cause cache path validation to fail.

Example occurrence

https://github.com/KSmanis/KSmanis/actions/runs/29380410882

@KSmanis
KSmanis marked this pull request as ready for review July 18, 2026 09:24
Copilot AI review requested due to automatic review settings July 18, 2026 09:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes cache save failures when prek cache dir outputs a colorized (ANSI-decorated) path (e.g., when PREK_COLOR=always), by stripping VT/ANSI control characters before passing the path downstream to caching logic.

Changes:

  • Strip VT/ANSI control sequences from prek cache dir stdout using Node’s built-in stripVTControlCharacters.
  • Add a regression test covering colorized CLI output.
  • Update the bundled dist/index.cjs output accordingly.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
test/prek.test.ts Adds a test ensuring ANSI escapes are removed from the CLI-reported cache directory path.
src/prek.ts Sanitizes prek cache dir output by stripping VT control characters before trimming/using the path.
dist/index.cjs Bundled build reflecting the source change to strip VT control characters.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@j178
j178 force-pushed the agent/strip-ansi-cache-path branch from 3bc26eb to 0776c7e Compare July 19, 2026 03:42
@j178
j178 force-pushed the agent/strip-ansi-cache-path branch from 0776c7e to 7075f66 Compare July 19, 2026 03:43
@j178 j178 changed the title Strip ANSI escapes from prek cache paths Disable color in prek cache directory output Jul 19, 2026
@j178 j178 changed the title Disable color in prek cache directory output Disable color in prek cache dir output Jul 19, 2026
@j178 j178 added the enhancement New feature or request label Jul 19, 2026
@j178

j178 commented Jul 19, 2026

Copy link
Copy Markdown
Owner

Thanks!

@j178
j178 merged commit 5337cb9 into j178:main Jul 19, 2026
9 checks passed
@KSmanis
KSmanis deleted the agent/strip-ansi-cache-path branch July 19, 2026 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants