Move buildnative to gyp

This commit is contained in:
Wilson Lin 2021-04-06 14:09:20 +10:00
parent 8c8c9cb12f
commit 16cea54a31
3 changed files with 16 additions and 5 deletions

View File

@ -8,6 +8,18 @@
"include_dirs": [
"native/target/release/",
],
"actions": [
{
"action_name": "build minify-html-ffi static library",
"inputs": ["native/src/lib.rs"],
"outputs": [
"native/target/release/libminify_html_ffi.a",
"native/target/release/minify_html_ffi.h",
"native/target/release/minify_html_ffi.lib",
],
"action": ["node", "./buildnative.js"],
}
],
"conditions": [
["OS=='mac'", {
"libraries": [

View File

@ -6,8 +6,7 @@ const common = {
types: "index.d.ts",
files: ["postinstall.js", "index.d.ts"],
scripts: {
build:
"node buildnative.js && node-gyp build && shx mv build/Release/index.node index.node",
build: "node-gyp build && shx mv build/Release/index.node index.node",
clean:
"cd native && cargo clean && cd .. && node-gyp clean && node-gyp configure && shx rm -f index.node",
postinstall: "node postinstall.js",

View File

@ -36,9 +36,9 @@ const downloadNativeBinary = async () => {
let binary;
try {
binary = await fetch(
`https://wilsonl.in/minify-html/bin/nodejs/${
pkg.version
}/${pkg.name.split("/")[1]}/${binaryName}.node.gz`
`https://wilsonl.in/minify-html/bin/nodejs/${pkg.version}/${
pkg.name.split("/")[1]
}/${binaryName}.node.gz`
);
} catch (e) {
if (e instanceof StatusError && attempt < MAX_DOWNLOAD_ATTEMPTS) {