Skip to content

Commit

Permalink
fix(index.js): remove unnecessary null check for github_1.context.repo
Browse files Browse the repository at this point in the history
fix(index.ts): remove unnecessary null check for context.repo
fix(pull-request.ts): remove unnecessary null check for core.info() calls
refactor(pull-request.ts): use explicit type for options in getHumanReadableTimestamp() function
  • Loading branch information
TGTGamer committed Feb 14, 2024
1 parent 02fae92 commit 14d997c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10886,7 +10886,7 @@ try {
const githubToken = process.env.GITHUB_TOKEN;
const wsDir = process.env.WSDIR;
const prNumber = (_b = (_a = github_1.context === null || github_1.context === void 0 ? void 0 : github_1.context.payload) === null || _a === void 0 ? void 0 : _a.pull_request) === null || _b === void 0 ? void 0 : _b.number;
const { owner, repo } = github_1.context === null || github_1.context === void 0 ? void 0 : github_1.context.repo;
const { owner, repo } = github_1.context.repo;
if (!githubToken) {
throw new Error('GitHub token not found');
}
Expand Down Expand Up @@ -10968,10 +10968,10 @@ const createSnapMessageText = (githubToken, repo, owner, prNumber) => __awaiter(
});
if (commits.length > 0) {
messageText = commits[commits.length - 1].commit.message;
core.info('Last commit message: ' + messageText);
core.info(`Last commit message: ${messageText}`);
}
}
core.info('Snap message Text: ' + messageText);
core.info(`Snap message Text: ${messageText}`);
return messageText;
});
/**
Expand Down
2 changes: 1 addition & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ try {
const githubToken = process.env.GITHUB_TOKEN
const wsDir: string = process.env.WSDIR!

Check warning on line 7 in index.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Forbidden non-null assertion
const prNumber = context?.payload?.pull_request?.number
const { owner, repo } = context?.repo
const { owner, repo } = context.repo

if (!githubToken) {
throw new Error('GitHub token not found')
Expand Down
8 changes: 4 additions & 4 deletions scripts/pull-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ const createSnapMessageText = async (

if (commits.length > 0) {
messageText = commits[commits.length - 1].commit.message
core.info('Last commit message: ' + messageText)
core.info(`Last commit message: ${messageText}`)
}
}

core.info('Snap message Text: ' + messageText)
core.info(`Snap message Text: ${messageText}`)
return messageText
}

Expand Down Expand Up @@ -92,7 +92,7 @@ const postOrUpdateComment = async (
*
*/
const getHumanReadableTimestamp = (): string => {
const options = {
const options: Intl.DateTimeFormatOptions = {
year: 'numeric',
month: 'long',
day: 'numeric',
Expand All @@ -101,7 +101,7 @@ const getHumanReadableTimestamp = (): string => {
second: '2-digit',
timeZone: 'UTC'
}
const date = new Date().toLocaleString('en-US', options as any)
const date = new Date().toLocaleString('en-US', options)

return `${date} UTC`
}
Expand Down

0 comments on commit 14d997c

Please sign in to comment.