Skip to content

Commit 8337671

Browse files
committed
Throw errors
1 parent 3879239 commit 8337671

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/configuration.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ export const prettierRepositoryPath = path.join(cwd, "./prettier");
66
export const targetRepositoriesPath = path.join(cwd, "./repos");
77
export const isCI = ci.isCI;
88
export const authToken = process.env.NODE_AUTH_TOKEN ?? "nothing";
9+
export const MAXIMUM_GITHUB_COMMENT_LENGTH = 65536;

src/log-text.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ function getLogTitle(command: Command): string {
4040

4141
const LONG_DIFF_THRESHOLD_IN_LINES = 50;
4242

43-
const MAXIMUM_GITHUB_COMMENT_LENGTH = 65536;
44-
4543
export function getLogText(
4644
result: ExecuteResultEntry[],
4745
command: Command,
@@ -72,7 +70,7 @@ export function getLogText(
7270
head.length +
7371
diff.length +
7472
/* Some room for blank lines */ 50;
75-
const shouldUpload = length > MAXIMUM_GITHUB_COMMENT_LENGTH;
73+
const shouldUpload = length > configuration.MAXIMUM_GITHUB_COMMENT_LENGTH;
7674
return {
7775
head,
7876
diff,
@@ -101,7 +99,7 @@ export function getLogText(
10199
formattedResult.length +
102100
lastGroup.length +
103101
/* Some room for blank lines */ 50 >
104-
MAXIMUM_GITHUB_COMMENT_LENGTH
102+
configuration.MAXIMUM_GITHUB_COMMENT_LENGTH
105103
) {
106104
group.push({
107105
length: formattedResult.length,

src/logger.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ import { getOctokit } from "./octokit";
55

66
let commentId: number | undefined;
77
async function logToIssueComment(logText: string, separateComment = false) {
8+
if (logText.length > configuration.MAXIMUM_GITHUB_COMMENT_LENGTH) {
9+
throw new Error(
10+
`The text is too long (maximum is ${configuration.MAXIMUM_GITHUB_COMMENT_LENGTH} characters, actual ${logText.length} characters)"}`,
11+
);
12+
}
13+
814
const octokit = getOctokit();
915
if (commentId === undefined || separateComment) {
1016
const comment = await octokit.issues.createComment({

0 commit comments

Comments
 (0)