File tree Expand file tree Collapse file tree 4 files changed +47
-4
lines changed Expand file tree Collapse file tree 4 files changed +47
-4
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ coverage
2121
2222# Compiled binary addons (http://nodejs.org/api/addons.html)
2323build /Release
24+ prebuilds
2425
2526# Dependency directory
2627# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
Original file line number Diff line number Diff line change 1+ const { spawnSync} = require ( 'child_process' ) ;
2+
3+ main ( ) . catch ( e => {
4+ throw e ;
5+ } ) ;
6+
7+ async function main ( ) {
8+ console . log ( 'Building distribution binary...' ) ; // eslint-disable-line no-console
9+
10+ const prebuildArch = getNodearch ( process . env . ARCH ) ;
11+
12+ // napi is forward compatible so we only build for two targets (Node and Electron)
13+ let prebuildScript = `prebuildify --napi --arch=${ prebuildArch } -t 12.0.0 -t [email protected] --strip` ; 14+
15+ if ( process . platform == 'linux' ) {
16+ prebuildScript = `${ prebuildScript } --tag-libc` ;
17+ }
18+
19+ spawnSync ( prebuildScript , {
20+ shell : true ,
21+ stdio : 'inherit' ,
22+ encoding : 'utf8' ,
23+ } ) ;
24+ }
25+
26+ /**
27+ * @param {string | undefined } arch the given architecture
28+ * @returns {string } the Node architecture to build for
29+ */
30+ function getNodearch ( arch ) {
31+ if ( ! arch ) {
32+ return process . arch ;
33+ }
34+ if ( arch === 'x86' ) {
35+ return 'ia32' ;
36+ } else {
37+ return arch ;
38+ }
39+ }
Original file line number Diff line number Diff line change 11const { promises : fs } = require ( 'fs' ) ;
22const path = require ( 'path' ) ;
33
4- const NSFW = require ( '../../build/Release/nsfw.node ' ) ;
4+ const NSFW = require ( '../../binding ' ) ;
55
66function NSFWFilePoller ( watchPath , eventCallback , debounceMS ) {
77 const { CREATED , DELETED , MODIFIED } = nsfw . actions ;
Original file line number Diff line number Diff line change 66 "scripts" : {
77 "install" : " node-gyp-build" ,
88 "lint" : " eslint js/src js/spec" ,
9- "test" : " yarn lint && node js/scripts/test.js"
9+ "test" : " yarn lint && node js/scripts/test.js" ,
10+ "prebuild" : " node ./js/scripts/prebuild.js"
1011 },
1112 "repository" : {
1213 "type" : " git" ,
2627 " js/src" ,
2728 " src" ,
2829 " includes" ,
29- " binding.gyp"
30+ " binding.gyp" ,
31+ " prebuilds"
3032 ],
3133 "homepage" : " https://github.com/axosoft/node-simple-file-watcher" ,
3234 "dependencies" : {
3739 "eslint" : " ^6.8.0" ,
3840 "executive" : " ^1.6.3" ,
3941 "fs-extra" : " ^7.0.0" ,
40- "mocha" : " ^7.1.1"
42+ "mocha" : " ^7.1.1" ,
43+ "prebuildify" : " ^4.1.2"
4144 },
4245 "keywords" : [
4346 " FileWatcher" ,
You can’t perform that action at this time.
0 commit comments