forked from okhiroyuki/nodejs-mobile-cordova
-
Notifications
You must be signed in to change notification settings - Fork 1
/
zipLibNode.js
34 lines (27 loc) · 847 Bytes
/
zipLibNode.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import * as zlib from "zlib";
import * as fs from "fs";
const LIB_FOLDER_PATH = "./libs/android/libnode/bin/";
const LIB_NAME = "libnode.so";
const LIB_NAME_GZ = `${LIB_NAME}.gz`;
const paths = [
`${LIB_FOLDER_PATH}armeabi-v7a/`,
`${LIB_FOLDER_PATH}arm64-v8a/`,
`${LIB_FOLDER_PATH}x86_64/`,
];
function compressLib(libFolderPath) {
const inputFilename = `${libFolderPath}${LIB_NAME}`;
const outputFilename = `${libFolderPath}${LIB_NAME_GZ}`;
if (fs.existsSync(inputFilename)) {
const input = fs.createReadStream(inputFilename);
const output = fs.createWriteStream(outputFilename);
const gzip = zlib.createGzip();
input
.pipe(gzip)
.pipe(output)
.on("close", () => {
console.log(`done => ${outputFilename}`);
fs.rmSync(inputFilename);
});
}
}
paths.forEach(compressLib);