1
0
mirror of https://gitlab.com/ceda_ei/git-alerts-bot synced 2025-11-05 14:50:08 +01:00

[refactor] Add eslint and do dependency injection

This commit is contained in:
Muthu Kumar
2018-11-27 21:05:55 +05:30
parent dce4394ff6
commit 968f1a8e1e
14 changed files with 2157 additions and 2110 deletions

View File

@@ -1,16 +1,24 @@
const github = function (data) {
const noun = "commit" + data.commits.length > 1?"s":"";
var text = data.commits.reduce((acc, curr, index) => {
if (index < 6) {
acc += `<a href='${curr.url}'>${curr.id.slice(0,6)}: ` +
`${curr.message}</a>\n`;
}
return acc;
}, `🔨 ${data.commits.length} ${noun}\n`);
if (data.commits.length > 6) {
text += `${data.commits.length - 6} more ${noun}.`;
}
return text;
const noun = "commit" + data.commits.length > 1 ? "s" : "";
var text = data.commits.reduce((acc, curr, index) => {
if (index < 6) {
acc += `<a href='${curr.url}'>${curr.id.slice(0,6)}: `
+ `${curr.message}</a>\n`;
}
return acc;
}, `🔨 ${data.commits.length} ${noun}\n`);
if (data.commits.length > 6) {
text += `${data.commits.length - 6} more ${noun}.`;
}
return text;
};
const gitlab = github;

View File

@@ -1,7 +1,9 @@
const github = function (body) {
if (body.commits && body.ref.match("^/refs/heads/")) return "commit";
if (body.commits && body.ref.match("^/refs/tags/")) return "tag";
if (body.issue) return "issue";
if (body.commits && body.ref.match("^/refs/heads/")) return "commit";
if (body.commits && body.ref.match("^/refs/tags/")) return "tag";
if (body.issue) return "issue";
};
module.exports = {github};

View File

@@ -1,4 +1,4 @@
module.exports = {
getEvent: require("./event"),
commit: require("./commit"),
getEvent: require("./event"),
commit: require("./commit"),
};