Simple-Updater/index.js

29 lines
772 B
JavaScript
Raw Normal View History

2024-06-07 22:21:02 -05:00
const fs = require("fs"),
2024-06-07 23:06:24 -05:00
path = require("path"),
shell = require("shelljs")
2024-06-07 22:21:02 -05:00
var configsPath = path.join(__dirname, "config")
var confPath = path.join(configsPath, "config.json")
if (!fs.existsSync(configsPath)) {
fs.mkdirSync(configsPath)
}
if (!fs.existsSync(confPath)) {
console.log("It would appear you have not created a config file yet! Generating one now.")
fs.cpSync(path.join(__dirname, "defaults/config.json"), confPath)
console.log("Done!")
2024-06-07 23:06:24 -05:00
}
function updateLoop() {
var config = JSON.parse(fs.readFileSync(confPath))
2024-08-09 02:11:07 -05:00
for (var i = 0; i < config.dirs.length; i++) {
shell.exec(`cd ${config.dirs[i]} && git pull`)
2024-06-07 23:06:24 -05:00
}
setTimeout(() => {
updateLoop()
2024-08-09 02:11:07 -05:00
}, config.updateSpeedMinutes * 60 * 1000);
2024-06-07 23:06:24 -05:00
}
updateLoop()