style: auto format

This commit is contained in:
GitHub Action
2021-01-11 00:47:42 +00:00
parent cb1506e535
commit d1aa038b28
2 changed files with 64 additions and 44 deletions

View File

@@ -1,32 +1,40 @@
const noFound = 'Auto: Route No Found';
module.exports = async ({github, context, core}, body, number) => {
module.exports = async ({ github, context, core }, body, number) => {
core.debug(`body: ${body}`);
const m = body.match(/```routes\r\n((.|\r\n)*)```/);
core.debug(`match: ${m}`);
let res = null;
const removeLabel = async () => github.issues.removeLabel({
issue_number: number,
owner: context.repo.owner,
repo: context.repo.repo,
name: noFound
}).catch((e) => { core.warning(e); });
if (m && m[1]) {
res = m[1].trim().split("\r\n");
core.info(`routes detected: ${res}`);
if (res.length > 0 && res[0] === "NOROUTE") {
core.info("PR stated no route, passing");
await removeLabel();
await github.issues.addLabels({
const removeLabel = async () =>
github.issues
.removeLabel({
issue_number: number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['Auto: No Route Needed']
}).catch((e) => { core.warning(e); });
name: noFound,
})
.catch((e) => {
core.warning(e);
});
if (m && m[1]) {
res = m[1].trim().split('\r\n');
core.info(`routes detected: ${res}`);
if (res.length > 0 && res[0] === 'NOROUTE') {
core.info('PR stated no route, passing');
await removeLabel();
await github.issues
.addLabels({
issue_number: number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['Auto: No Route Needed'],
})
.catch((e) => {
core.warning(e);
});
return;
} else if (res.length > 0) {
@@ -36,14 +44,18 @@ module.exports = async ({github, context, core}, body, number) => {
}
}
core.info("seems no route found, failing");
core.info('seems no route found, failing');
await github.issues.addLabels({
issue_number: number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: [noFound]
}).catch((e) => { core.warning(e); });
await github.issues
.addLabels({
issue_number: number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: [noFound],
})
.catch((e) => {
core.warning(e);
});
throw "Please follow the PR rules: failed to detect route";
throw 'Please follow the PR rules: failed to detect route';
};