Skip to content

Commit 579638d

Browse files
committed
chore(cli): use joinAnd + getErrorCause helpers in utils/ misc
- basics/vfs-extract.mts: missingTools list now renders as prose via joinAnd('a, b, and c'). - terminal/iocraft.mts: inline `e instanceof Error ? e.message : String(e)` swapped for getErrorCause(e). require() of a native binding can throw non-Error values, so the safe-stringify with UNKNOWN_ERROR fallback is correct here. No behavior change for Error throws.
1 parent bb6c44d commit 579638d

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

packages/cli/src/utils/basics/vfs-extract.mts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { createHash } from 'node:crypto'
1616
import { homedir } from 'node:os'
1717
import path from 'node:path'
1818

19+
import { joinAnd } from '@socketsecurity/lib/arrays'
1920
import { getDefaultLogger } from '@socketsecurity/lib/logger'
2021
import { normalizePath } from '@socketsecurity/lib/paths/normalize'
2122
import { spawn } from '@socketsecurity/lib/spawn'
@@ -176,7 +177,7 @@ export async function extractBasicsTools(
176177
const missingTools = tools.filter(t => !extractedPaths[t])
177178
if (missingTools.length) {
178179
throw new Error(
179-
`socket-basics VFS extraction returned ${Object.keys(extractedPaths).length}/${tools.length} tools (missing: ${missingTools.join(', ')}); the SEA bundle is incomplete — rebuild with all basics tools included`,
180+
`socket-basics VFS extraction returned ${Object.keys(extractedPaths).length}/${tools.length} tools (missing: ${joinAnd(missingTools)}); the SEA bundle is incomplete — rebuild with all basics tools included`,
180181
)
181182
}
182183

packages/cli/src/utils/terminal/iocraft.mts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
import { createRequire } from 'node:module'
99

10+
import { getErrorCause } from '../error/errors.mts'
11+
1012
import type iocraft from '@socketaddon/iocraft'
1113

1214
// Re-export iocraft types for direct access when needed.
@@ -27,7 +29,7 @@ function getIocraft(): typeof iocraft {
2729
iocraftInstance = loaded.default || loaded
2830
} catch (e) {
2931
throw new Error(
30-
`could not load @socketaddon/iocraft native module (${e instanceof Error ? e.message : String(e)}); reinstall socket-cli to pull the prebuilt for your platform, or check that your platform (${process.platform}-${process.arch}) has a published prebuilt`,
32+
`could not load @socketaddon/iocraft native module (${getErrorCause(e)}); reinstall socket-cli to pull the prebuilt for your platform, or check that your platform (${process.platform}-${process.arch}) has a published prebuilt`,
3133
)
3234
}
3335
}

0 commit comments

Comments
 (0)