summaryrefslogtreecommitdiff
path: root/includes/watcher.js
blob: 33f614a34b155872b569f7bfee1ac18d6cc3f3cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
const watch = require('node-watch');
const fs = require('fs');
let lastUpdate = 0;

watch('..', { recursive: true }, function(evt, name) {
    if (name.includes("includes/users") || name.includes("includes/tokens")) return;

    if (new Date().getTime() - lastUpdate > 60000) {
        let buildFile = fs.readFileSync("/opt/spotify/build.txt").toString().trim();
        let build = parseInt(buildFile.replace(/^(.*?)(\d+)$/gm, "$2")) + 1;
        fs.writeFileSync("/opt/spotify/build.txt", buildFile.replace(/^(.*?)(\d+)$/gm, "$1") + build);
        lastUpdate = new Date().getTime();
    }
});