|
|
@ -3,20 +3,34 @@ |
|
|
|
const path = require("path"); |
|
|
|
const path = require("path"); |
|
|
|
const fs = require("fs"); |
|
|
|
const fs = require("fs"); |
|
|
|
const glob = require("glob"); |
|
|
|
const glob = require("glob"); |
|
|
|
|
|
|
|
const streamBuffers = require("stream-buffers"); |
|
|
|
const _ = require("underscore"); |
|
|
|
const _ = require("underscore"); |
|
|
|
|
|
|
|
|
|
|
|
const writeReport = (releaseDir, err, result, callback) => fs.writeFile(path.join(releaseDir, "report.json"), JSON.stringify({ |
|
|
|
const writeReport = (releaseDir, err, result, callback) => { |
|
|
|
|
|
|
|
const readable = new streamBuffers.ReadableStreamBuffer(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readable |
|
|
|
|
|
|
|
.pipe(fs.createWriteStream(path.join(releaseDir, "report.json"))) |
|
|
|
|
|
|
|
.on("error", callback) |
|
|
|
|
|
|
|
.on("finish", callback); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readable.put(JSON.stringify({ |
|
|
|
"date": Date.now(), |
|
|
|
"date": Date.now(), |
|
|
|
err, |
|
|
|
err, |
|
|
|
result |
|
|
|
result |
|
|
|
}), callback); |
|
|
|
})); |
|
|
|
|
|
|
|
readable.stop(); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const readReport = (releaseDir, callback) => fs.readFile(path.join(releaseDir, "report.json"), (err, dataBuffer) => { |
|
|
|
const readReport = (releaseDir, callback) => { |
|
|
|
if (err) { |
|
|
|
const writable = new streamBuffers.WritableStreamBuffer(); |
|
|
|
return callback(err); |
|
|
|
const readStream = fs.createReadStream(path.join(releaseDir, "report.json")); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const data = dataBuffer.toString(); |
|
|
|
readStream |
|
|
|
|
|
|
|
.pipe(writable) |
|
|
|
|
|
|
|
.on("error", callback) |
|
|
|
|
|
|
|
.on("finish", () => { |
|
|
|
|
|
|
|
const data = writable.getContentsAsString(); |
|
|
|
|
|
|
|
|
|
|
|
if (!data) { |
|
|
|
if (!data) { |
|
|
|
return callback("ReportFileNotFound"); |
|
|
|
return callback("ReportFileNotFound"); |
|
|
@ -24,6 +38,7 @@ const readReport = (releaseDir, callback) => fs.readFile(path.join(releaseDir, " |
|
|
|
|
|
|
|
|
|
|
|
return callback(null, JSON.parse(data)); |
|
|
|
return callback(null, JSON.parse(data)); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
exports.writeReport = writeReport; |
|
|
|
exports.writeReport = writeReport; |
|
|
|
|
|
|
|
|
|
|
|