From 7d76c611042ee36e33e69089916e4035733a4d6c Mon Sep 17 00:00:00 2001 From: fan xia Date: Thu, 7 Dec 2023 00:14:44 +0800 Subject: [PATCH] fix --- addon/package.json | 74 +++++++++++++++++++++++----------------------- addon/postbuild.js | 5 ++-- 2 files changed, 40 insertions(+), 39 deletions(-) diff --git a/addon/package.json b/addon/package.json index df4237e..27f59e6 100644 --- a/addon/package.json +++ b/addon/package.json @@ -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" + ] } \ No newline at end of file diff --git a/addon/postbuild.js b/addon/postbuild.js index f4a1b51..46baf41 100644 --- a/addon/postbuild.js +++ b/addon/postbuild.js @@ -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) \ No newline at end of file