/
task.js
34 lines (29 loc) · 1.19 KB
/
task.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
33
34
(function () {
'use strict';
const https = require('https');
const markbotMain = require('electron').remote.require('./app/markbot-main');
const group = taskDetails.group;
const repo = taskDetails.options.repo;
const username = taskDetails.options.username;
const id = 'live-website';
const label = 'Online';
const errors = [`The website @@https://${username.toLowerCase()}.github.io/${repo}/@@ is not online. Double check that all the commits have been synced & that the \`index.html\` file, on GitHub’s website, follows the naming conventions`];
const opts = {
method: 'HEAD',
host: `${username.toLowerCase()}.github.io`,
path: `/${repo}/`,
};
markbotMain.send('check-group:item-new', group, id, label);
markbotMain.send('check-group:item-computing', group, id, label);
https.get(opts, function (res) {
if(res.statusCode >= 200 && res.statusCode <= 299) {
markbotMain.send('check-group:item-complete', group, id, label);
} else {
markbotMain.send('check-group:item-complete', group, id, label, errors);
}
done();
}).on('error', function (e) {
markbotMain.send('check-group:item-complete', group, id, label, errors);
done();
});
}());