Skip to content

Commit 4ebfb47

Browse files
committed
fix(releases/socket-btm): normalize win32 → win in getPlatformArch
Add PLATFORM_MAP to convert win32 to win for file/folder names, matching the convention used across all Socket repositories. This ensures consistency with getBinaryAssetName which already uses 'win' for Windows platforms.
1 parent db2d8af commit 4ebfb47

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

src/releases/socket-btm.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,17 @@ export type SocketBtmReleaseConfig =
8585
| SocketBtmBinaryConfig
8686
| SocketBtmAssetConfig
8787

88+
/**
89+
* Map Node.js platform to socket-btm asset platform naming.
90+
* Uses 'win' instead of 'win32' for file/folder names.
91+
*/
92+
const PLATFORM_MAP: Record<string, string> = {
93+
__proto__: null,
94+
darwin: 'darwin',
95+
linux: 'linux',
96+
win32: 'win',
97+
}
98+
8899
/**
89100
* Map Node.js arch to socket-btm asset arch naming.
90101
*/
@@ -333,22 +344,28 @@ export function getBinaryName(
333344

334345
/**
335346
* Get platform-arch identifier for directory structure.
347+
* Uses 'win' instead of 'win32' for file/folder names.
336348
*
337349
* @param platform - Target platform
338350
* @param arch - Target architecture
339351
* @param libc - Linux libc variant (optional)
340-
* @returns Platform-arch identifier (e.g., 'darwin-arm64', 'linux-x64-musl')
352+
* @returns Platform-arch identifier (e.g., 'darwin-arm64', 'linux-x64-musl', 'win-x64')
341353
*/
342354
export function getPlatformArch(
343355
platform: Platform,
344356
arch: Arch,
345357
libc?: Libc | undefined,
346358
): string {
359+
const mappedPlatform = PLATFORM_MAP[platform]
360+
if (!mappedPlatform) {
361+
throw new Error(`Unsupported platform: ${platform}`)
362+
}
363+
347364
const mappedArch = ARCH_MAP[arch]
348365
if (!mappedArch) {
349366
throw new Error(`Unsupported architecture: ${arch}`)
350367
}
351368

352369
const muslSuffix = platform === 'linux' && libc === 'musl' ? '-musl' : ''
353-
return `${platform}-${mappedArch}${muslSuffix}`
370+
return `${mappedPlatform}-${mappedArch}${muslSuffix}`
354371
}

test/unit/releases-socket-btm.test.mts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,13 @@ describe('releases/socket-btm', () => {
105105
expect(getPlatformArch('linux', 'arm64', 'musl')).toBe('linux-arm64-musl')
106106
})
107107

108-
it('should return correct identifier for win32-x64', () => {
109-
expect(getPlatformArch('win32', 'x64')).toBe('win32-x64')
108+
it('should return correct identifier for win-x64', () => {
109+
expect(getPlatformArch('win32', 'x64')).toBe('win-x64')
110110
})
111111

112112
it('should ignore libc for non-linux platforms', () => {
113113
expect(getPlatformArch('darwin', 'arm64', 'musl')).toBe('darwin-arm64')
114-
expect(getPlatformArch('win32', 'x64', 'musl')).toBe('win32-x64')
114+
expect(getPlatformArch('win32', 'x64', 'musl')).toBe('win-x64')
115115
})
116116

117117
it('should throw for unsupported architecture', () => {

0 commit comments

Comments
 (0)