-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecode.js
35 lines (30 loc) · 1.07 KB
/
decode.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
35
const zlib = require('zlib');
const walkDir = require('./lib/walk-dir')
const path = require('path');
const fs = require('fs');
const dir = "./pack/"
const dst = "./unpack/"
walkDir.walk(dir, (d, file) => {
let localFileName = path.join(d, file)
let dstFileName = path.join(dst, file)
if(localFileName.indexOf(".gitignore") === -1){
fs.readFile(localFileName, 'utf-8', (err, data) => {
data = Buffer.from(data, 'base64')
zlib.unzip(data, (err, buffer) => {
if (err) {
console.log("zlib.inflate err", JSON.stringify(err))
} else {
fs.writeFile(dstFileName, buffer.toString(), (err) => {
if (err) {
console.log(`fs.writeFile err`, JSON.stringify(err))
} else {
console.log(`fs.writeFile ${dstFileName} ok`)
}
})
}
})
})
} else {
console.log(`filters ${localFileName}`)
}
});