diff --git a/build_list.js b/build_list.js index d1fb1cfaea7668a9cde7f64aeaf8b1bd7e076adb..6b986608777fbb2373a6f4f633f8835f73bb4a08 100644 --- a/build_list.js +++ b/build_list.js @@ -54,6 +54,11 @@ fetch(adawayUri) hostnames = createdLevel2Trackers(trackers, hostnames) console.log("Trackers list finished") }) +.then(toto => { + if (listHasNoChanges()) { + throw "No changes in trackers, abort updating." + } +}) .then(toto => { return printTrackers() }) @@ -147,6 +152,14 @@ function toLevel2Domain(hostname) { } } + +function listHasNoChanges() { + // Compare actual list with the builded one (without the createdAt field!) + const oldTrackers = require("./" + outputFile).trackers + return JSON.stringify(trackers) == JSON.stringify(oldTrackers) +} + + function printTrackers() { return JSON.stringify({ trackers: trackers, @@ -154,6 +167,8 @@ function printTrackers() { }) } + + function saveTrackersFile(trackersJson) { fs.writeFileSync(outputFile, trackersJson) }