From 0faf8bffe5023a9840945377d63003a1ced13d6a Mon Sep 17 00:00:00 2001 From: "kts of kettek(MindFire)" Date: Tue, 15 Jan 2019 22:19:46 -0500 Subject: [PATCH] Add code --- index.js | 25 +++++++++++++++++++++++++ package.json | 14 ++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 index.js create mode 100644 package.json diff --git a/index.js b/index.js new file mode 100644 index 0000000..4894ddf --- /dev/null +++ b/index.js @@ -0,0 +1,25 @@ +var config = module.parent._require('config.js'); + +module.exports = function(plugin) { + plugin.defaults({ + "interval": 60 * 1000 + }); + var sgit = require('simple-git')(config['wiki_dir']); + + function update() { + sgit.pull(function(err, update) { + plugin.emit("pre-update"); + if (err) { + plugin.emit("error"); + console.log('E: ' + 'autogit: ' + err); + } + plugin.emit("post-update"); + }) + } + + sgit.checkIsRepo(function(isRepo = true) { + console.log('I: ' + 'autogit: updating every ' + plugin.conf['interval'] + 'ms'); + plugin.emit('load'); + setInterval(update, plugin.conf['interval']); + }); +}; diff --git a/package.json b/package.json new file mode 100644 index 0000000..61112e7 --- /dev/null +++ b/package.json @@ -0,0 +1,14 @@ +{ + "name": "ngwiki-plugin-autogit", + "version": "1.0.0", + "description": "ngwiki plugin that periodically updates the git repository located at wiki_dir", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "Ketchetwahmeegwun T. Southall", + "license": "GPL-3.0", + "dependencies": { + "simple-git": "^1.91.0" + } +}