forked from asg017/sqlite-vec
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.cjs
More file actions
31 lines (24 loc) · 792 Bytes
/
index.cjs
File metadata and controls
31 lines (24 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const { join } = require("node:path");
const { arch, platform } = require("node:process");
const { statSync } = require("node:fs");
const ENTRYPOINT_BASE_NAME = "vec0";
function extensionSuffix(platform) {
if (platform === "win32") return "dll";
if (platform === "darwin") return "dylib";
return "so";
}
function getLoadablePath() {
const loadablePath = join(
__dirname,
"dist",
`${ENTRYPOINT_BASE_NAME}.${extensionSuffix(platform)}`
);
if (!statSync(loadablePath, { throwIfNoEntry: false })) {
throw new Error(`Loadable extension for sqlite-vec not found at ${loadablePath}. Was the extension built? Run: make loadable`);
}
return loadablePath;
}
function load(db) {
db.loadExtension(getLoadablePath());
}
module.exports = { getLoadablePath, load };