Skip to content

Commit 03a0eda

Browse files
committed
Simplify github.context.payload.comment
1 parent b9ebcf1 commit 03a0eda

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

eslint.config.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ export default defineConfig(
1919
eslintConfigPrettier,
2020
{
2121
rules: {
22+
curly: "error",
23+
24+
/* eslint-plugin-unicorn */
2225
"unicorn/template-indent": "error",
2326

2427
/* eslint-plugin-simple-import-sort */

src/get-issue-comment.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/index.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import path from "node:path";
2+
import * as github from "@actions/github";
23
import { IS_TRIGGERED_BY_GITHUB_ISSUE_COMMENT } from "./constants.ts";
34
import { reportsDirectory, THROW_EXECUTE_ERROR } from "./constants.ts";
45
import { executeCommand } from "./execute-command.ts";
5-
import { getIssueComment } from "./get-issue-comment.ts";
66
import * as logger from "./logger.ts";
77
import { getReport, stringifyReport } from "./report.ts";
88
import { reportOnGithubIssue } from "./report-on-github-issue.ts";
@@ -11,14 +11,17 @@ import { writeFile } from "./utilities.ts";
1111
async function run() {
1212
let commandString;
1313
if (IS_TRIGGERED_BY_GITHUB_ISSUE_COMMENT) {
14-
const comment = getIssueComment();
15-
commandString = comment.body as string;
14+
const { comment } = github.context.payload;
15+
if (!comment) {
16+
throw new Error("'github.context.payload.comment' is missing.");
17+
}
18+
commandString = comment.body;
1619
} else {
1720
commandString = process.argv.splice(2)[0];
1821
}
1922

20-
if (!commandString) {
21-
throw new Error("Please enter some commands.");
23+
if (typeof commandString !== "string" || !commandString) {
24+
throw new Error("Missing required command string.");
2225
}
2326

2427
await logger.brief(

0 commit comments

Comments
 (0)