File tree Expand file tree Collapse file tree 4 files changed +295
-3
lines changed Expand file tree Collapse file tree 4 files changed +295
-3
lines changed Original file line number Diff line number Diff line change @@ -40,3 +40,6 @@ local.properties
4040buck-out /
4141\. buckd /
4242* .keystore
43+
44+ # Other
45+ vpnJni /* .zip
Original file line number Diff line number Diff line change 1818 "build-vpn-lib" : " yarn build-ics-ovpn; yarn gen-vpn-lib; yarn patch-vpn-lib" ,
1919 "build-ics-ovpn" : " sh scripts/build-ics-ovpn.sh" ,
2020 "gen-vpn-lib" : " sh scripts/gen-vpn-lib.sh" ,
21- "patch-vpn-lib" : " sh scripts/patch-vpn-lib.sh"
21+ "patch-vpn-lib" : " sh scripts/patch-vpn-lib.sh" ,
22+ "zip-vpn-jni" : " node vpnJni/zip-vpn-jni.js"
2223 },
2324 "repository" : {
2425 "type" : " git" ,
3839 "licenseFilename" : " LICENSE" ,
3940 "readmeFilename" : " README.md" ,
4041 "devDependencies" : {
42+ "archiver" : " ^5.3.0" ,
4143 "clang-format" : " ^1.4.0" ,
4244 "prettier" : " ^2.3.2"
4345 }
Original file line number Diff line number Diff line change 1+ const fs = require ( 'fs' ) ;
2+ const archiver = require ( 'archiver' ) ;
3+
4+ const jniLibPath = __dirname + '/../vpnLib/src/main/jniLibs' ;
5+ const jniDirList = fs . readdirSync ( jniLibPath ) ;
6+
7+ jniDirList . forEach ( ( item ) => {
8+ if ( item === '.DS_Store' ) return ;
9+
10+ const output = fs . createWriteStream ( `${ __dirname } /${ item } .zip` ) ;
11+ const archive = archiver ( 'zip' , {
12+ zlib : { level : 9 } ,
13+ } ) ;
14+
15+ output . on ( 'close' , ( ) => {
16+ const compressedSize = ( archive . pointer ( ) / 1024 / 1024 ) . toFixed ( 2 ) ;
17+ console . log ( `Finish compressing [${ item } ] - ${ compressedSize } MB` ) ;
18+ } ) ;
19+
20+ output . on ( 'end' , ( ) => {
21+ console . log ( 'Data has been drained' ) ;
22+ } ) ;
23+
24+ archive . on ( 'warning' , ( err ) => {
25+ if ( err . code === 'ENOENT' ) {
26+ console . log ( 'Warning ' + err ) ;
27+ } else {
28+ throw err ;
29+ }
30+ } ) ;
31+
32+ archive . on ( 'error' , ( err ) => {
33+ throw err ;
34+ } ) ;
35+
36+ archive . pipe ( output ) ;
37+ archive . directory ( `${ jniLibPath } /${ item } /` , false ) ;
38+ archive . finalize ( ) ;
39+ } ) ;
You can’t perform that action at this time.
0 commit comments