report-processor refactored to use stream-buffers

dependabot/npm_and_yarn/BuildServer/eslint-7.2.0
Inga 🏳‍🌈 8 years ago
parent 945426d2e8
commit 8f1f4269ef
  1. 31
      BuildServer/lib/report-processor.js
  2. 65
      BuildServer/package.json

@ -3,27 +3,42 @@
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");
}
return callback(null, JSON.parse(data));
});
});
};
exports.writeReport = writeReport;

@ -26,6 +26,7 @@
"recursive-tree-copy": "0.0.1",
"serve-favicon": "^2.3.2",
"serve-static": "^1.11.1",
"stream-buffers": "^3.0.1",
"uglify-js": "^2.7.5",
"underscore": "^1.8.3"
},
@ -38,19 +39,61 @@
},
"extends": "eslint:all",
"rules": {
"quotes": ["warn", "double"],
"quotes": [
"warn",
"double"
],
"require-jsdoc": "off",
"func-names": ["warn", "never"],
"max-len": ["warn", { "code": 140 }],
"operator-linebreak": ["warn", "before"],
"padded-blocks": ["warn", "never"],
"dot-notation": ["warn", { "allowPattern": "^[a-z]+(_[a-z]+)+$" }],
"linebreak-style": ["warn", "windows"],
"func-names": [
"warn",
"never"
],
"max-len": [
"warn",
{
"code": 140
}
],
"operator-linebreak": [
"warn",
"before"
],
"padded-blocks": [
"warn",
"never"
],
"dot-notation": [
"warn",
{
"allowPattern": "^[a-z]+(_[a-z]+)+$"
}
],
"linebreak-style": [
"warn",
"windows"
],
"no-console": "off",
"dot-location": ["warn", "property"],
"object-curly-spacing": ["warn", "always"],
"one-var": ["warn", { "initialized": "never" }],
"no-extra-parens": ["warn", "all", { "nestedBinaryExpressions": false }]
"dot-location": [
"warn",
"property"
],
"object-curly-spacing": [
"warn",
"always"
],
"one-var": [
"warn",
{
"initialized": "never"
}
],
"no-extra-parens": [
"warn",
"all",
{
"nestedBinaryExpressions": false
}
]
}
}
}

Loading…
Cancel
Save