* Probe a filesystem path and classify the result so callers can * distinguish "not present" from "present but unreadable". Using * fs.existsSync collapses ENOENT and EACCES/EPERM/EIO into a bare * boolean, which means a permissions or I/O fault masquerades as * "missing" and leads to silently w
(p: string)
| 81 | * outcomes distinct so callers can warn/exit/proceed appropriately. |
| 82 | */ |
| 83 | function probePath(p: string): "missing" | "exists" | "unreadable" { |
| 84 | try { |
| 85 | fs.statSync(p); |
| 86 | return "exists"; |
| 87 | } catch (err) { |
| 88 | const code = (err as NodeJS.ErrnoException).code; |
| 89 | if (code === "ENOENT") return "missing"; |
| 90 | return "unreadable"; |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * Escape regex metacharacters in a string so it can be safely embedded |
no outgoing calls
no test coverage detected
searching dependent graphs…