This commit is contained in:
Jay 2020-08-25 16:47:12 +08:00
parent fa3715c748
commit 657d47722f
4 changed files with 7 additions and 6 deletions

View File

@ -1,10 +1,11 @@
const path = require('path')
const { loadBinding } = require('@node-rs/helper') const { loadBinding } = require('@node-rs/helper')
try { try {
// __dirname means load native addon from current dir // __dirname means load native addon from current dir
// 'index' means native addon name is `index` // 'index' means native addon name is `index`
// the value of this two arguments was decided by `build` script in `package.json` // the value of this two arguments was decided by `build` script in `package.json`
module.exports = loadBinding(__dirname, 'index') module.exports = loadBinding(path.join(__dirname, '..', `rs-diff-${process.platform}`), 'index')
} catch (e) { } catch (e) {
try { try {
module.exports = require(`@swc-node/core-${platform()}`) module.exports = require(`@swc-node/core-${platform()}`)

View File

@ -1,6 +1,6 @@
{ {
"name": "rs-diff-darwin", "name": "rs-diff-darwin",
"version": "0.0.1", "version": "0.0.2",
"description": "Template project for writing node package with napi-rs", "description": "Template project for writing node package with napi-rs",
"repository": "https://git.trj.tw/nodejs/rs-diff.git", "repository": "https://git.trj.tw/nodejs/rs-diff.git",
"license": "MIT", "license": "MIT",

View File

@ -1,6 +1,6 @@
{ {
"name": "rs-diff-linux", "name": "rs-diff-linux",
"version": "0.0.1", "version": "0.0.2",
"description": "Template project for writing node package with napi-rs", "description": "Template project for writing node package with napi-rs",
"repository": "https://git.trj.tw/nodejs/rs-diff.git", "repository": "https://git.trj.tw/nodejs/rs-diff.git",
"license": "MIT", "license": "MIT",

View File

@ -1,6 +1,6 @@
{ {
"name": "rs-diff", "name": "rs-diff",
"version": "0.0.1", "version": "0.0.2",
"description": "Template project for writing node package with napi-rs", "description": "Template project for writing node package with napi-rs",
"author": "Jay <jay@trj.tw>", "author": "Jay <jay@trj.tw>",
"main": "index.js", "main": "index.js",
@ -58,7 +58,7 @@
} }
}, },
"optionalDependencies": { "optionalDependencies": {
"rs-diff-darwin": "^0.0.1", "rs-diff-darwin": "^0.0.2",
"rs-diff-linux": "^0.0.1" "rs-diff-linux": "^0.0.2"
} }
} }