parent
8f1f4269ef
commit
6dba4b3201
@ -0,0 +1,34 @@ |
||||
"use strict"; |
||||
|
||||
const fs = require("fs"); |
||||
const path = require("path"); |
||||
const zlib = require("zlib"); |
||||
const glob = require("glob"); |
||||
const async = require("async"); |
||||
const settings = require("./settings"); |
||||
|
||||
glob("**\\report.json", { "cwd": settings.releasepath }, (globErr, files) => { |
||||
if (globErr) { |
||||
return console.log(globErr); |
||||
} |
||||
|
||||
return async.parallelLimit(files.map((file) => (callback) => { |
||||
const originalPath = path.join(settings.releasepath, file); |
||||
const newPath = `${originalPath}.gz`; |
||||
|
||||
console.log(file); |
||||
fs.createReadStream(originalPath) |
||||
.pipe(zlib.createGzip()) |
||||
.pipe(fs.createWriteStream(newPath)) |
||||
.on("error", callback) |
||||
.on("finish", () => { |
||||
fs.unlink(originalPath, callback); |
||||
}); |
||||
}), 100, (err) => { |
||||
if (err) { |
||||
console.log(err); |
||||
} |
||||
|
||||
console.log("Done"); |
||||
}); |
||||
}); |
Loading…
Reference in new issue