Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
SOVLOOKUP committed Dec 6, 2023
1 parent 09caaf9 commit 7d76c61
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 39 deletions.
74 changes: 37 additions & 37 deletions addon/package.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
{
"name": "rubick-native-addon",
"version": "0.0.0",
"main": "index.js",
"types": "index.d.ts",
"napi": {
"name": "rubick-native-addon",
"triples": {
"additional": [
"aarch64-unknown-linux-gnu",
"aarch64-unknown-linux-musl",
"x86_64-unknown-linux-musl",
"aarch64-apple-darwin",
"universal-apple-darwin",
"aarch64-pc-windows-msvc",
"i686-pc-windows-msvc"
]
}
},
"engines": {
"node": ">= 10"
},
"scripts": {
"artifacts": "napi artifacts",
"build": "napi build --platform --release && node ./postbuild.js",
"build:debug": "napi build --platform",
"prepublishOnly": "node ./prepub.js && napi prepublish -t npm",
"universal": "napi universal",
"version": "napi version"
},
"devDependencies": {
"@napi-rs/cli": "^2.16.3"
},
"files": [
"index.js",
"index.d.ts"
]
{
"name": "rubick-native-addon",
"version": "0.0.0",
"main": "index.js",
"types": "index.d.ts",
"napi": {
"name": "rubick-native-addon",
"triples": {
"additional": [
"aarch64-unknown-linux-gnu",
"aarch64-unknown-linux-musl",
"x86_64-unknown-linux-musl",
"aarch64-apple-darwin",
"universal-apple-darwin",
"aarch64-pc-windows-msvc",
"i686-pc-windows-msvc"
]
}
},
"engines": {
"node": ">= 10"
},
"scripts": {
"artifacts": "napi artifacts",
"build": "napi build --platform --release && node ./postbuild.js",
"build:debug": "napi build --platform",
"prepublishOnly": "node ./prepub.js && napi prepublish -t npm",
"universal": "napi universal",
"version": "napi version"
},
"devDependencies": {
"@napi-rs/cli": "^2.16.5"
},
"files": [
"index.js",
"index.d.ts"
]
}
5 changes: 3 additions & 2 deletions addon/postbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ const path = require("path");

const ijs_path = path.join(__dirname, "index.js")
const ijs = readFileSync(ijs_path, "utf-8")
const twoijs = ijs.split('\n\nmodule.exports')
const newijs = 'const nativeBinding = (new Function(`require`,`__dirname`,`' + twoijs[0].replaceAll('`', '\\`').replaceAll('$', '\\$') + '\nreturn nativeBinding`))(require,__dirname)\nmodule.exports' + twoijs[1]
const twoijs = ijs.split('binding\`)\n}\n')

const newijs = 'const nativeBinding = (new Function(`require`,`__dirname`,`' + twoijs[0].replaceAll('`', '\\`').replaceAll('$', '\\$') + 'binding\\`)\n}\nreturn nativeBinding`))(require,__dirname)\n' + twoijs[1]

writeFileSync(ijs_path, newijs)

0 comments on commit 7d76c61

Please sign in to comment.