24 lines
514 B
JavaScript
24 lines
514 B
JavaScript
module.exports = async (plugin, app) => {
|
|
plugin.defaults({
|
|
"interval": 30 * 1000,
|
|
})
|
|
|
|
const sgit = require('simple-git')(app.config.srd)
|
|
|
|
async function update() {
|
|
try {
|
|
await sgit.pull()
|
|
} catch(err) {
|
|
plugin.error(err)
|
|
}
|
|
}
|
|
|
|
if (await sgit.checkIsRepo()) {
|
|
await update()
|
|
plugin.log('updating every', plugin.config['interval'] + 'ms')
|
|
setInterval(update, plugin.config['interval'])
|
|
} else {
|
|
plugin.error('target directory is not a git repository')
|
|
}
|
|
}
|