|
|
|
@ -3,20 +3,34 @@ |
|
|
|
|
const path = require("path"); |
|
|
|
|
const fs = require("fs"); |
|
|
|
|
const glob = require("glob"); |
|
|
|
|
const streamBuffers = require("stream-buffers"); |
|
|
|
|
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(), |
|
|
|
|
err, |
|
|
|
|
result |
|
|
|
|
}), callback); |
|
|
|
|
})); |
|
|
|
|
readable.stop(); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const readReport = (releaseDir, callback) => fs.readFile(path.join(releaseDir, "report.json"), (err, dataBuffer) => { |
|
|
|
|
if (err) { |
|
|
|
|
return callback(err); |
|
|
|
|
} |
|
|
|
|
const readReport = (releaseDir, callback) => { |
|
|
|
|
const writable = new streamBuffers.WritableStreamBuffer(); |
|
|
|
|
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) { |
|
|
|
|
return callback("ReportFileNotFound"); |
|
|
|
@ -24,6 +38,7 @@ const readReport = (releaseDir, callback) => fs.readFile(path.join(releaseDir, " |
|
|
|
|
|
|
|
|
|
return callback(null, JSON.parse(data)); |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
exports.writeReport = writeReport; |
|
|
|
|
|
|
|
|
|