refactor(fs): use mkdirSafe recursive and align test mocks

Replace try/access/mkdir pattern with single mkdirSafe call in ssh-key-manager; drop unused mkdir mocks from stt/tts/repo tests and mock fs-safe's mkdirSafe instead; add zod peer dep extension to pnpm workspace; note EACCES-tolerant startup in troubleshooting doc.
This commit is contained in:
Chris Scott committed 2026-07-23 22:59:05 -04:00
1 parent f20d8ffb71
commit 376bd67f1b
7 files changed
+49 -22

No files matched your search

+2 -10
View File
@@ -9,11 +9,7 @@ import { mkdirSafe } from './fs-safe'
const SSH_KEYS_DIR = join(getWorkspacePath(), '.ssh-keys')
async function ensureSSHKeysDir(): Promise<void> {
try {
await fs.access(SSH_KEYS_DIR)
} catch {
await mkdirSafe(SSH_KEYS_DIR, { mode: 0o700 })
}
await mkdirSafe(SSH_KEYS_DIR, { mode: 0o700 })
}
async function validateSSHKey(keyPath: string): Promise<boolean> {
@@ -167,11 +163,7 @@ export function generateSSHConfig(entries: SSHConfigEntry[]): string {
export async function writeSSHConfig(configPath: string, configContent: string): Promise<void> {
const dir = join(getWorkspacePath(), 'config')
try {
await fs.access(dir)
} catch {
await mkdirSafe(dir, { mode: 0o700 })
}
await mkdirSafe(dir, { mode: 0o700 })
await fs.writeFile(configPath, configContent, { mode: 0o600 })
}