You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
982 B
37 lines
982 B
8 years ago
|
"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");
|
||
|
|
||
8 years ago
|
const streamsNumber = 100;
|
||
|
|
||
8 years ago
|
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);
|
||
|
});
|
||
8 years ago
|
}), streamsNumber, (err) => {
|
||
8 years ago
|
if (err) {
|
||
|
console.log(err);
|
||
|
}
|
||
|
|
||
|
console.log("Done");
|
||
|
});
|
||
|
});
|