diff --git a/package.json b/package.json index ed3a55a..776265b 100644 --- a/package.json +++ b/package.json @@ -23,12 +23,16 @@ "wrapper.js", "package.json", "README.md", - "LICENSE" + "LICENSE", + "src", + "scripts/build-from-source.js", + "binding.gyp" ], "scripts": { "prebuild": "prebuildify --napi --strip --tag-libc", "format": "prettier --write \"./**/*.{js,json,md}\"", "build": "node-gyp rebuild -j 8 --debug --verbose", + "install": "node scripts/build-from-source.js", "test": "mocha" }, "engines": { diff --git a/scripts/build-from-source.js b/scripts/build-from-source.js new file mode 100644 index 0000000..4602008 --- /dev/null +++ b/scripts/build-from-source.js @@ -0,0 +1,13 @@ +#!/usr/bin/env node + +const {spawn} = require('child_process'); + +if (process.env.npm_config_build_from_source === 'true') { + build(); +} + +function build() { + spawn('node-gyp', ['rebuild'], { stdio: 'inherit', shell: true }).on('exit', function (code) { + process.exit(code); + }); +}