Refactor addon path resolution and rename Windows addon

Simplifies the logic for resolving the ffmpeg addon path by dynamically constructing the filename from process.platform and process.arch. Also renames the Windows x64 addon file to ffmpegAddon.win32.x64.node for consistency.
This commit is contained in:
手瓜一十雪 2025-10-30 11:29:54 +08:00
parent fbd00b2576
commit 2da5d242f7
2 changed files with 4 additions and 12 deletions

View File

@ -19,20 +19,12 @@ function getAddonPath(binaryPath: string): string {
const platformName = platform();
const archName = arch();
let addonFileName: string;
if (platformName === 'win32' && archName === 'x64') {
addonFileName = 'ffmpegAddon.win.x64.node';
} else if (platformName === 'linux' && archName === 'x64') {
addonFileName = 'ffmpegAddon.linux.x64.node';
} else if (platformName === 'linux' && archName === 'arm64') {
addonFileName = 'ffmpegAddon.linux.arm64.node';
} else if (platformName === 'darwin' && archName === 'arm64') {
addonFileName = 'ffmpegAddon.darwin.arm64.node';
} else {
let addonFileName: string = process.platform + '.' + process.arch;
let addonPath = path.join(binaryPath, "./native/ffmpeg/", `${addonFileName}.node`);
if (existsSync(addonPath)) {
throw new Error(`Unsupported platform: ${platformName} ${archName}`);
}
return path.join(binaryPath, "./native/ffmpeg/", addonFileName);
return addonPath;
}
/**