File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed
bindings/pkgs/@duckdb/node-bindings Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change 1- module . exports = require ( `@duckdb/node-bindings-${ process . platform } -${ process . arch } /duckdb.node` ) ;
1+ const getRuntimePlatformArch = ( ) => `${ process . platform } -${ process . arch } ` ;
2+
3+ /**
4+ * @throw Error if there isn't any available native binding for the current platform/arch.
5+ */
6+ const getNativeNodeBinding = ( runtimePlatformArch ) => {
7+ switch ( runtimePlatformArch ) {
8+ case `linux-x64` :
9+ return require ( '@duckdb/node-bindings-linux-x64/duckdb.node' ) ;
10+ case 'linux-arm64' :
11+ return require ( '@duckdb/node-bindings-linux-arm64/duckdb.node' ) ;
12+ case 'darwin-arm64' :
13+ return require ( '@duckdb/node-bindings-darwin-arm64/duckdb.node' ) ;
14+ case 'darwin-x64' :
15+ return require ( '@duckdb/node-bindings-darwin-x64/duckdb.node' ) ;
16+ case 'win32-x64' :
17+ return require ( '@duckdb/node-bindings-win32-x64/duckdb.node' ) ;
18+ default :
19+ const [ platform , arch ] = runtimePlatformArch . split ( '-' )
20+ throw new Error ( `Error loading duckdb native binding: unsupported arch '${ arch } ' for platform '${ platform } '` ) ;
21+ }
22+ }
23+
24+ module . exports = getNativeNodeBinding ( getRuntimePlatformArch ( ) ) ;
You can’t perform that action at this time.
0 commit comments