@@ -29,25 +29,23 @@ export interface SocketBtmAssetConfig {
2929 /** @internal Discriminator fields */
3030 bin ?: never
3131 /** Working directory (defaults to process.cwd()). */
32- cwd ?: string
32+ cwd ?: string | undefined
3333 /** Download destination directory. @default 'build/downloaded' */
34- downloadDir ?: string
34+ downloadDir ?: string | undefined
3535 /** @internal Discriminator fields */
3636 libc ?: never
3737 /** Output filename. @default resolved asset name */
38- output ?: string
38+ output ?: string | undefined
3939 /** Suppress log messages. @default false */
40- quiet ?: boolean
40+ quiet ?: boolean | undefined
4141 /** Remove macOS quarantine attribute after download. @default false */
42- removeMacOSQuarantine ?: boolean
42+ removeMacOSQuarantine ?: boolean | undefined
4343 /** Specific release tag to download. */
44- tag ?: string
44+ tag ?: string | undefined
4545 /** @internal Discriminator fields */
4646 targetArch ?: never
4747 /** @internal Discriminator fields */
4848 targetPlatform ?: never
49- /** Tool/package name for directory structure and release matching. */
50- tool : string
5149}
5250
5351/**
@@ -57,25 +55,23 @@ export interface SocketBtmBinaryConfig {
5755 /** @internal Discriminator field */
5856 asset ?: never
5957 /** Binary/executable name (without extension). @default tool */
60- bin ?: string
58+ bin ?: string | undefined
6159 /** Working directory (defaults to process.cwd()). */
62- cwd ?: string
60+ cwd ?: string | undefined
6361 /** Download destination directory. @default 'build/downloaded' */
64- downloadDir ?: string
62+ downloadDir ?: string | undefined
6563 /** Linux libc variant. Auto-detected if not specified. */
66- libc ?: Libc
64+ libc ?: Libc | undefined
6765 /** Suppress log messages. @default false */
68- quiet ?: boolean
66+ quiet ?: boolean | undefined
6967 /** Remove macOS quarantine attribute after download. @default true */
70- removeMacOSQuarantine ?: boolean
68+ removeMacOSQuarantine ?: boolean | undefined
7169 /** Specific release tag to download. */
72- tag ?: string
70+ tag ?: string | undefined
7371 /** Target architecture (defaults to current arch). */
74- targetArch ?: Arch
72+ targetArch ?: Arch | undefined
7573 /** Target platform (defaults to current platform). */
76- targetPlatform ?: Platform
77- /** Tool/package name for directory structure and release matching. */
78- tool : string
74+ targetPlatform ?: Platform | undefined
7975}
8076
8177/**
@@ -162,27 +158,30 @@ export function detectLibc(): Libc | undefined {
162158/**
163159 * Download a release from socket-btm.
164160 *
165- * @param config - Download configuration
161+ * @param tool - Tool/package name for release matching (e.g., 'lief', 'curl')
162+ * @param options - Download configuration
166163 * @returns Path to the downloaded file
167164 */
168165export async function downloadSocketBtmRelease (
169- config : SocketBtmReleaseConfig ,
166+ tool : string ,
167+ options : SocketBtmReleaseConfig | undefined ,
170168) : Promise < string > {
171- const { cwd, downloadDir, quiet = false , tag, tool } = config
169+ const config = Object . assign ( Object . create ( null ) , options )
170+ const { cwd, downloadDir, quiet = false , tag } = config
172171
173172 // Auto-generate toolPrefix from tool name (follows socket-btm tag pattern: {tool}-{date}-{commit})
174173 const toolPrefix = `${ tool } -`
175174
176175 let downloadConfig : DownloadGitHubReleaseConfig
177176
178177 // Infer type from presence of 'asset' field
179- if ( 'asset' in config ) {
178+ if ( options && 'asset' in options ) {
180179 // Asset download
181- const {
182- asset ,
183- output ,
184- removeMacOSQuarantine = false ,
185- } = config as SocketBtmAssetConfig
180+ const assetConfig = Object . assign (
181+ Object . create ( null ) ,
182+ options as SocketBtmAssetConfig ,
183+ )
184+ const { asset , output , removeMacOSQuarantine = false } = assetConfig
186185
187186 // Resolve asset pattern to actual asset name if needed.
188187 let resolvedAsset : string
@@ -252,13 +251,17 @@ export async function downloadSocketBtmRelease(
252251 }
253252 } else {
254253 // Binary download
254+ const binaryConfig = Object . assign (
255+ Object . create ( null ) ,
256+ options as SocketBtmBinaryConfig | undefined ,
257+ )
255258 const {
256259 bin,
257260 libc = detectLibc ( ) ,
258261 removeMacOSQuarantine = true ,
259262 targetArch = getArch ( ) ,
260263 targetPlatform = getPlatform ( ) ,
261- } = config as SocketBtmBinaryConfig
264+ } = binaryConfig
262265
263266 // Default bin to tool if not provided (like brew/cargo)
264267 const baseName = bin || tool
0 commit comments