Skip to content

Commit c78ab48

Browse files
committedAug 26, 2021
style: npm run fix
1 parent 2f49a90 commit c78ab48

File tree

4 files changed

+36
-23
lines changed

4 files changed

+36
-23
lines changed
 

‎README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ jobs:
3030
runs-on: ubuntu-latest
3131

3232
steps:
33-
- name: check for reminder
34-
uses: agrc/create-reminder-action@v1.0.0
33+
- name: check for reminder
34+
uses: agrc/create-reminder-action@v1.0.0
3535
```
3636
3737
## Package for distribution
3838
3939
GitHub Actions will run the entry point from the action.yml. Packaging assembles the code into one file that can be checked in to Git, enabling fast and reliable execution and preventing the need to check in node_modules.
4040
41-
Actions are run from GitHub repos. Packaging the action will create a packaged action in the dist folder.
41+
Actions are run from GitHub repos. Packaging the action will create a packaged action in the dist folder.
4242
4343
Run prepare
4444

‎index.js

+21-10
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
const core = require('@actions/core');
22
const github = require('@actions/github');
3-
const {getReminder, addReminderToBody} = require('./utilities');
3+
const { getReminder, addReminderToBody } = require('./utilities');
44
const LABEL = 'reminder';
55

66
function getIssueProps(context) {
77
return {
88
owner: context.repository.owner,
99
repo: context.repository.name,
10-
issue_number: context.issue.number
10+
issue_number: context.issue.number,
1111
};
1212
}
1313

1414
function createComment(octokit, context, body) {
1515
return octokit.rest.issues.createComment({
1616
...getIssueProps(context),
17-
body
17+
body,
1818
});
1919
}
2020

@@ -23,20 +23,22 @@ function updateIssue(octokit, context, reminder) {
2323

2424
return octokit.rest.issues.update({
2525
...getIssueProps(context),
26-
body
26+
body,
2727
});
2828
}
2929

3030
async function run() {
3131
const context = github.context.payload;
3232
const owner = core.getInput('repositoryOwner');
3333
const repository = core.getInput('repository');
34-
const octokit = github.getOctokit(core.getInput('repoToken', {required:true}));
34+
const octokit = github.getOctokit(
35+
core.getInput('repoToken', { required: true })
36+
);
3537
let reminder;
3638

3739
context.repository = {
3840
owner,
39-
name: repository.split('/')[1]
41+
name: repository.split('/')[1],
4042
};
4143

4244
try {
@@ -50,10 +52,13 @@ async function run() {
5052
return;
5153
}
5254
core.endGroup();
53-
5455
} catch (error) {
5556
core.startGroup('create error comment');
56-
await createComment(octokit, context, `@${context.sender.login} we had trouble parsing your reminder. Try:\n\n\`/remind me [what] [when]\``);
57+
await createComment(
58+
octokit,
59+
context,
60+
`@${context.sender.login} we had trouble parsing your reminder. Try:\n\n\`/remind me [what] [when]\``
61+
);
5762
core.endGroup();
5863

5964
core.setFailed(error);
@@ -65,7 +70,7 @@ async function run() {
6570
core.info(JSON.stringify(getIssueProps(context), null, 1));
6671
await octokit.rest.issues.addLabels({
6772
...getIssueProps(context),
68-
labels: [LABEL]
73+
labels: [LABEL],
6974
});
7075
core.endGroup();
7176

@@ -74,7 +79,13 @@ async function run() {
7479
core.endGroup();
7580

7681
core.startGroup('add reminder comment');
77-
await createComment(octokit, context, `@${context.sender.login} set a reminder for **${reminder.when.toLocaleDateString()}**`);
82+
await createComment(
83+
octokit,
84+
context,
85+
`@${
86+
context.sender.login
87+
} set a reminder for **${reminder.when.toLocaleDateString()}**`
88+
);
7889
core.endGroup();
7990
}
8091

‎index.test.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,27 @@ describe('getReminder', () => {
77
const reminder = getReminder(issueContext, REFERENCE_DATE);
88

99
expect(reminder).toEqual({
10-
who: 'Codertocat', when: new Date(2017, 6, 6, 9, 0, 0, 0), what: 'do something'
10+
who: 'Codertocat',
11+
when: new Date(2017, 6, 6, 9, 0, 0, 0),
12+
what: 'do something',
1113
});
1214
});
1315
test('returns null if not a slash command', () => {
1416
const reminder = getReminder({
1517
...issueContext,
1618
comment: {
17-
body: 'not a command'
18-
}
19+
body: 'not a command',
20+
},
1921
});
2022

2123
expect(reminder).toBeNull();
22-
})
24+
});
2325
test('returns null if the command is not remind', () => {
2426
const reminder = getReminder({
2527
...issueContext,
2628
comment: {
27-
body: '/not a command'
28-
}
29+
body: '/not a command',
30+
},
2931
});
3032

3133
expect(reminder).toBeNull();
@@ -37,7 +39,7 @@ describe('addReminderToBody', () => {
3739
const reminder = {
3840
who: '@hello',
3941
what: 'do it',
40-
when: '1/2/3'
42+
when: '1/2/3',
4143
};
4244
const body = addReminderToBody('this is the body', reminder);
4345

@@ -51,7 +53,7 @@ describe('addReminderToBody', () => {
5153
const reminder = {
5254
who: '@someone',
5355
what: 'to something',
54-
when: '1/1/2021'
56+
when: '1/1/2021',
5557
};
5658
const existing = `
5759
this is the body

‎utilities.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ function addReminderToBody(body, reminder) {
3939

4040
reminders.push({
4141
id,
42-
...reminder
42+
...reminder,
4343
});
4444

45-
const comment = `\n\n<!-- bot: ${JSON.stringify({reminders})} -->`
45+
const comment = `\n\n<!-- bot: ${JSON.stringify({ reminders })} -->`;
4646
if (match) {
4747
return body.replace(regex, comment);
4848
}

0 commit comments

Comments
 (0)
Please sign in to comment.