@cake-hub/cake-screenshot_diffs
Version:
A CAKE Screenshot diffing tool that includes a setup to comapre two given resources by screenshots taken from the available pages.
32 lines (26 loc) • 769 B
JavaScript
const fs = require ("fs-extra");
class ParseJSON {
constructor (filePath) {
this._filePath = filePath;
}
async parse () {
try {
const rawJSONString = await fs.readFile (this._filePath, 'utf8');
return JSON.parse (rawJSONString);
} catch (e) {
console.error ("ParseJSON", "parse ()", e);
return null;
}
}
async write (jsonContent) {
try {
const rawJSONString = JSON.stringify (jsonContent);
await fs.writeFile (this._filePath, rawJSONString);
return this._filePath;
} catch (e) {
console.error ("ParseJSON", "jsonContent ()", e);
return null;
}
}
}
module.exports = ParseJSON;