16 lines
570 B
JavaScript
16 lines
570 B
JavaScript
const path = require('path')
|
|
const { loadBinding } = require('@node-rs/helper')
|
|
|
|
try {
|
|
// __dirname means load native addon from current dir
|
|
// 'index' means native addon name is `index`
|
|
// the value of this two arguments was decided by `build` script in `package.json`
|
|
module.exports = loadBinding(path.join(__dirname, '..', `rs-diff-${process.platform}`), 'index')
|
|
} catch (e) {
|
|
try {
|
|
module.exports = require(`@swc-node/core-${platform()}`)
|
|
} catch (e) {
|
|
throw new TypeError('Not compatible with your platform. Error message: ' + e.message)
|
|
}
|
|
}
|