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 55 "main" : " js/src/index.js" ,
66 "scripts" : {
77 "lint" : " eslint js/src js/spec" ,
8- "test" : " yarn lint && node js/scripts/test.js"
8+ "test" : " yarn lint && node js/scripts/test.js" ,
9+ "prebuild" : " node ./js/scripts/prebuild.js"
910 },
1011 "repository" : {
1112 "type" : " git" ,
2526 " js/src" ,
2627 " src" ,
2728 " includes" ,
28- " binding.gyp"
29+ " binding.gyp" ,
30+ " prebuilds"
2931 ],
3032 "homepage" : " https://github.com/axosoft/node-simple-file-watcher" ,
3133 "dependencies" : {
3638 "eslint" : " ^6.8.0" ,
3739 "executive" : " ^1.6.3" ,
3840 "fs-extra" : " ^7.0.0" ,
39- "mocha" : " ^7.1.1"
41+ "mocha" : " ^7.1.1" ,
42+ "prebuildify" : " ^4.1.2"
4043 },
4144 "keywords" : [
4245 " FileWatcher" ,
You can’t perform that action at this time.
0 commit comments