Skip to content

Commit 5a8cd87

Browse files
committed
Remove platform and arch options from dlxBinary
Users should never request binaries for platforms they aren't running on since they cannot be executed. The function now always uses the current system's platform and architecture.
1 parent ca51b61 commit 5a8cd87

2 files changed

Lines changed: 1 addition & 18 deletions

File tree

registry/src/lib/dlx-binary.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ export interface DlxBinaryOptions {
2727
cacheTtl?: number | undefined
2828
/** Force re-download even if cached. */
2929
force?: boolean | undefined
30-
/** Platform override (defaults to current platform). */
31-
platform?: NodeJS.Platform | undefined
32-
/** Architecture override (defaults to current arch). */
33-
arch?: string | undefined
3430
/** Additional spawn options. */
3531
spawnOptions?: SpawnOptions | undefined
3632
}
@@ -235,12 +231,10 @@ export async function dlxBinary(
235231
spawnExtra?: SpawnExtra | undefined,
236232
): Promise<DlxBinaryResult> {
237233
const {
238-
arch = os.arch(),
239234
cacheTtl = DLX_BINARY_CACHE_TTL,
240235
checksum,
241236
force = false,
242237
name,
243-
platform: targetPlatform = process.platform,
244238
spawnOptions,
245239
url,
246240
} = { __proto__: null, ...options } as DlxBinaryOptions
@@ -249,7 +243,7 @@ export async function dlxBinary(
249243
const cacheDir = getDlxCachePath()
250244
const cacheKey = generateCacheKey(url)
251245
const cacheEntryDir = path.join(cacheDir, cacheKey)
252-
const binaryName = name || `binary-${targetPlatform}-${arch}`
246+
const binaryName = name || `binary-${process.platform}-${os.arch()}`
253247
const binaryPath = normalizePath(path.join(cacheEntryDir, binaryName))
254248

255249
let downloaded = false

test/registry/dlx-binary.test.mts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -229,17 +229,6 @@ describe('dlx-binary', () => {
229229
expect(metadata).toHaveProperty('timestamp')
230230
expect(metadata).toHaveProperty('url')
231231
})
232-
233-
it('should handle platform and arch overrides', async () => {
234-
const { binaryPath } = await dlxBinary(['--version'], {
235-
arch: 'arm64',
236-
platform: 'linux',
237-
spawnOptions: { cwd: tmpDir },
238-
url: `${baseUrl}/test-binary?test=platform-override`,
239-
})
240-
241-
expect(binaryPath).toContain('linux-arm64')
242-
})
243232
})
244233

245234
describe('listDlxCache', () => {

0 commit comments

Comments
 (0)