-
Notifications
You must be signed in to change notification settings - Fork 2
/
binding.js
31 lines (28 loc) · 955 Bytes
/
binding.js
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 helper = require('./helpers/buildPath.js')
const path = require('path')
const debug = require('debug')('leveldb')
if (!process.versions.electron) {
// Electron has its own crash handler, and segfault-handler
// uses NAN which is a hassle, so only load outside electron
try {
const SegfaultHandler = require('segfault-handler')
SegfaultHandler.registerHandler('crash.log')
} catch (e) {
debug('[leveldb] segfault handler is not installed. If you run into crashing issues, install it with `npm i -D segfault-handler` to get debug info on native crashes')
}
}
let bindings
const pathToSearch = helper.getPath()
if (pathToSearch) {
const rpath = path.join(__dirname, pathToSearch, '/node-leveldb.node')
try {
bindings = require(rpath)
} catch (e) {
debug(e)
debug('[leveldb] did not find lib in ', rpath)
}
}
if (!bindings) {
bindings = require('bindings')('node-leveldb.node')
}
module.exports = bindings