minify-html/nodejs/build.sh

30 lines
784 B
Bash
Raw Normal View History

2020-01-19 19:12:51 -05:00
#!/usr/bin/env bash
set -e
# Builds hyperbuild-nodejs with native module for local testing.
# Built package will only run current platform and Node.js version.
pushd "$(dirname "$0")"
npm install
rm -rf dist
npx tsc
if [ -f native/Cargo.toml.orig ]; then
echo 'Not altering Node.js Cargo.toml file'
else
cp native/Cargo.toml native/Cargo.toml.orig
2020-01-25 22:47:06 -05:00
# Don't use -i as macOS requires '' argument but then Ubuntu will treat as pattern.
sed 's%^hyperbuild = .*$%hyperbuild = { path = "../.." }%' native/Cargo.toml.orig > native/Cargo.toml
2020-01-19 19:12:51 -05:00
fi
npx neon build --release
mv native/Cargo.toml.orig native/Cargo.toml
2020-07-03 10:00:10 -04:00
binary_name="$(node -e 'console.log([process.platform, process.arch, process.versions.modules].join("__"))')"
2020-01-19 19:12:51 -05:00
2020-07-03 10:00:10 -04:00
mv native/index.node "dist/$binary_name.node"
2020-01-19 19:12:51 -05:00
popd