Skip to content

Commit

Permalink
Add install script to optionally build from source
Browse files Browse the repository at this point in the history
Closes #191, closes #157
  • Loading branch information
devongovett committed Nov 4, 2024
1 parent 3d5de6a commit 8efcb0f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
13 changes: 13 additions & 0 deletions scripts/build-from-source.js
Original file line number Diff line number Diff line change
@@ -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);
});
}

0 comments on commit 8efcb0f

Please sign in to comment.