()
| 20 | } |
| 21 | |
| 22 | async function getRustAPI(): Promise<RustNativeBindingAPI> { |
| 23 | let nativeBinding = null; |
| 24 | if (platform === 'darwin' && arch === 'x64') { |
| 25 | // $FlowFixMe |
| 26 | nativeBinding = nativeBindingRequire( |
| 27 | './napi/rust-node-addon.darwin-x64.node', |
| 28 | ); |
| 29 | } else if (platform === 'darwin' && arch === 'arm64') { |
| 30 | // $FlowFixMe |
| 31 | nativeBinding = nativeBindingRequire( |
| 32 | './napi/rust-node-addon.darwin-arm64.node', |
| 33 | ); |
| 34 | } else if (platform === 'linux' && arch === 'x64') { |
| 35 | // $FlowFixMe |
| 36 | nativeBinding = nativeBindingRequire( |
| 37 | './napi/rust-node-addon.linux-x64-gnu.node', |
| 38 | ); |
| 39 | } else if (platform === 'linux' && arch === 'arm64') { |
| 40 | // $FlowFixMe |
| 41 | nativeBinding = nativeBindingRequire( |
| 42 | './napi/rust-node-addon.linux-arm64-gnu.node', |
| 43 | ); |
| 44 | } else { |
| 45 | throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`); |
| 46 | } |
| 47 | |
| 48 | if (!nativeBinding) { |
| 49 | throw new Error('Failed to load Rust native binding'); |
| 50 | } |
| 51 | |
| 52 | return nativeBinding; |
| 53 | } |
| 54 | |
| 55 | export { getRustAPI }; |
no outgoing calls
no test coverage detected