make startup take a screenshot for diff

This commit is contained in:
Martin Donnelly 2019-10-23 18:30:03 +01:00
parent 95f4700faa
commit ac0fc1e9fb

View File

@ -112,8 +112,14 @@ class ChangeDetection extends Scraper {
};
});
const timestamp = dateFormat(now, 'yyyymmddHHMM');
const screenshotPath = `${this.path}/screenshots/${filename}-${timestamp}`;
if (!fs.existsSync(oldFile)) {
fs.writeFileSync(oldFile, innerText.body, 'utf-8');
stats.screenshot = screenshotPath;
await this._makeScreenshotV2(this.page, screenshotPath, null);
this.stats.set(filename, stats);
}
else {
@ -130,8 +136,6 @@ class ChangeDetection extends Scraper {
if (levenshtein !== 0) {
logger.info('Changed...');
const timestamp = dateFormat(now, 'yyyymmddHHMM');
const screenshotPath = `${this.path}/screenshots/${filename}-${timestamp}`;
stats.previousScreenshot = stats.screenshot;
stats.previousChange = stats.lastSaved;