-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunzip.js
37 lines (34 loc) · 856 Bytes
/
unzip.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
36
37
// unzip 64bit zip file
// ex) zip -p zipfile > file
const exec = require("child_process").exec
const fs = require("fs")
exports = module.exports = {
unzip_to_path: function(filePath, dest, callback) {
if (filePath && dest) {
if (fs.existsSync(dest)) {
callback()
return
}
let command = `/usr/bin/unzip -p ${filePath} > ${dest}`
exec(command, (error, stdout, stderr) => {
if (error == null) {
fs.unlink(filePath, (err) => {
if (err) {
throw err
}
callback()
})
}
if (stdout) {
console.log("stdout: " + stdout)
}
if (stderr) {
console.log("stderr: " + stderr)
}
if (error !== null) {
console.log("Exec error: " + error)
}
})
}
},
}