Skip to content

Commit b2d8c01

Browse files
committed
refac: remove bindings, look native code manually
1 parent 4e31fb4 commit b2d8c01

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

lib/api.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
1+
import { existsSync } from 'node:fs'
2+
import { createRequire } from 'node:module'
3+
import { dirname, join } from 'node:path'
14
import { fileURLToPath } from 'node:url'
2-
import bindings from 'bindings'
5+
import debug from 'debug'
36

4-
const moduleRoot = bindings.getRoot(fileURLToPath(import.meta.url))
7+
const log = debug('flac:native')
8+
const moduleRoot = dirname(dirname(fileURLToPath(import.meta.url)))
9+
const libPath = ['build/Debug', 'build/Release']
10+
.map((p) => join(moduleRoot, p, 'flac-bindings.node'))
11+
.find((p) => existsSync(p))
12+
13+
log('Module root path:', moduleRoot)
14+
log('Library path:', libraryPath ?? '<not found>')
15+
if (!libPath) {
16+
throw new Error(
17+
'Could not find the the native addon. Please ensure the install script has run or run it manually.',
18+
)
19+
}
20+
21+
const require = createRequire(import.meta.url)
522
export const {
623
_coverageFlush,
724
_testAsync,
@@ -17,4 +34,4 @@ export const {
1734
metadata,
1835
metadata0,
1936
napiVersion,
20-
} = bindings({ bindings: 'flac-bindings.node', module_root: moduleRoot })
37+
} = require(libPath)

package-lock.json

Lines changed: 0 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
"author": "melchor9000",
4242
"license": "ISC",
4343
"dependencies": {
44-
"bindings": "^1.5.0",
4544
"debug": "^4.3.4",
4645
"detect-libc": "^2.0.1",
4746
"tar-stream": "^3.0.0"
@@ -76,7 +75,7 @@
7675
},
7776
"engines": {
7877
"node": ">=20.0.0",
79-
"electron": "^29.0.0"
78+
"electron": ">=29.0.0"
8079
},
8180
"binary": {
8281
"napi_versions": [
@@ -95,4 +94,4 @@
9594
"LICENSE",
9695
"readme.md"
9796
]
98-
}
97+
}

0 commit comments

Comments
 (0)