git-pull-cron
v1.0.0
Published
Git clone a repo into a folder and schedule a cron job to pull updates
Downloads
3
Readme
git-pull-cron
Git clone a repo into a folder and schedule a cron job to pull updates from the remote origin.
Installation
$ npm install git-pull-cron
Usage
var gitPullCron = require('git-pull-cron');
/*
- Clone given repo into /dev/my-repo, replacing what's already there
- Schedule cron to run every weekday (Mon-Fri) at 11:30am
- When cron task runs, a `git pull origin master` will be performed
- Once cron task has run the callback will get invoked with latest commit info
*/
gitPullCron.init('git://my-domain.com/my-repo.git', '/dev/my-repo', '00 30 11 * * 1-5', function(err, commit) {
if (err) {
return console.error(err.stack);
}
console.log('Updated to commit: ' + commit.id);
});
API
.init(gitRepoUrl, localFolderPath, cronSpec, updateCallback)
Clone remote Git repository to given local folder path and schedule a cron job
to git pull
updates.
Params:
gitRepoUrl
- URL to remote git repo, should be actionable bygit
command-line executable.localFolderPath
- Where the repository should be cloned to in the filesystem. Will get clobbered prior to cloning.cronSpec
- The cron schedule spec, see cronupdateCallback
- OPTIONAL. A callback(err, commit)
which gets invoked for every update performed. Thecommit
parameter is an instance ofCommit
from gift.
Returns: A Promise
which resolves to the CronJob
instance.
.jobs
The current list of CronJob
instances that have been setup through init()
.
This is useful in case you wish to modify or stop cron jobs.
LICENSE
MIT - see LICENSE.md