-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgitPoller.js
32 lines (28 loc) · 1.04 KB
/
gitPoller.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* eslint-disable no-console */
const Bluebird = require('bluebird');
const config = require('config');
const debug = require('debug')('gitnotifier:gitPoller');
const path = require('path');
const GitNotifier = require('./lib/gitNotifier');
const gitNotifier = new GitNotifier();
(async () => {
await Bluebird.each(config.get('repoList'), async (repo) => {
const repoUrl = repo.gitUrl;
debug(`${repoUrl} => ${path.basename(repoUrl)}`);
try {
await gitNotifier.cloneRepoIfNotExists(repoUrl);
const { ansiLogAndDiff, localSha1, remoteSha1 } = await gitNotifier.checkForNewCommits(repoUrl);
if (ansiLogAndDiff) {
const info = await gitNotifier.sendEmailNotification(repoUrl, ansiLogAndDiff, localSha1, remoteSha1);
debug(`Email sent: ${info.response}`);
}
}
catch (err) {
console.error(`Bailing out on repo ${repoUrl}:`, err);
}
});
})()
.catch(err => {
console.warn(err);
process.exit(1);
});