Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .claude/hooks/setup-security-tools/index.mts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { fileURLToPath } from 'node:url'

import { whichSync } from '@socketsecurity/lib/bin'
import { downloadBinary } from '@socketsecurity/lib/dlx/binary'
import { safeDelete } from '@socketsecurity/lib/fs'
import { getDefaultLogger } from '@socketsecurity/lib/logger'
import { getSocketHomePath } from '@socketsecurity/lib/paths/socket'
import { spawn, spawnSync } from '@socketsecurity/lib/spawn'
Expand Down Expand Up @@ -161,7 +162,7 @@ async function setupZizmor(): Promise<boolean> {
await fs.copyFile(extractedBin, binPath)
await fs.chmod(binPath, 0o755)
} finally {
await fs.rm(extractDir, { recursive: true, force: true }).catch(() => {})
await safeDelete(extractDir).catch(() => {})
}

logger.log(`Installed to ${binPath}`)
Expand Down
8 changes: 5 additions & 3 deletions packages/cli/scripts/sync-checksums.mts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { pipeline } from 'node:stream/promises'

import { safeDelete } from '@socketsecurity/lib/fs'

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const packageRoot = path.join(__dirname, '..')
Expand Down Expand Up @@ -135,15 +137,15 @@ async function fetchGitHubReleaseChecksums(
const checksums = parseChecksums(content)

// Clean up.
await fs.rm(tempDir, { recursive: true })
await safeDelete(tempDir)

console.log(
` Parsed ${Object.keys(checksums).length} checksums from checksums.txt`,
)
return checksums
} catch (error) {
console.log(` Failed to download checksums.txt: ${error.message}`)
await fs.rm(tempDir, { recursive: true }).catch(() => {})
await safeDelete(tempDir).catch(() => {})
// Fall through to download assets.
}
}
Expand Down Expand Up @@ -183,7 +185,7 @@ async function fetchGitHubReleaseChecksums(
await fs.unlink(assetPath)
}
} finally {
await fs.rm(tempDir, { recursive: true }).catch(() => {})
await safeDelete(tempDir).catch(() => {})
}

return checksums
Expand Down