-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharchive.js
More file actions
29 lines (28 loc) · 816 Bytes
/
archive.js
File metadata and controls
29 lines (28 loc) · 816 Bytes
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
var fs = require("fs")
var archiver = require("archiver")
const log = require("./log").sub("archive")
module.exports = (source, destination) =>
new Promise((resolve, reject) => {
var output = fs.createWriteStream(destination)
var archive = archiver("zip", {
zlib: { level: 9 }, // Sets the compression level.
})
output.on("close", function () {
// log.debug(archive.pointer() + " total bytes")
log.debug("success archiving", destination)
resolve()
})
archive.on("warning", function (err) {
if (err.code === "ENOENT") {
// log warning
log.warn(err)
} else {
// throw error
reject(err)
}
})
archive.on("error", reject)
archive.pipe(output)
archive.directory(source, false)
archive.finalize()
})