Add code
This commit is contained in:
commit
0faf8bffe5
25
index.js
Normal file
25
index.js
Normal file
|
@ -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']);
|
||||
});
|
||||
};
|
14
package.json
Normal file
14
package.json
Normal file
|
@ -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"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user