fix(cli): validate that --cwd directory exists before execution (#4658)
* fix(cli): validate that --cwd directory exists before execution When a non-existent directory is passed via --cwd/-d, commitlint now prints a clear error message and exits with code 1 instead of silently returning exit code 0. Closes #4595 * fix(cli): validate --cwd is a directory, not just that it exists Replaces existsSync with statSync + isDirectory to reject file paths that would cause uncontrolled errors downstream in git operations. * fix(cli): differentiate --cwd error messages by errno code The catch-all handler for statSync failures reported all errors (EACCES, EPERM, ENOTDIR) as "does not exist". Now checks error.code and only uses that message for ENOENT; other errors surface the actual errno code.
O
Omar Yusuf Abdi committed
cf80f75745593f4f018cac301a91f23316c974fd
Parent: fce263f
Committed by GitHub <noreply@github.com>
on 3/15/2026, 12:56:41 PM