Skip to content

Commit e9cae0e

Browse files
committed
Brief
1 parent 5a7a410 commit e9cae0e

File tree

6 files changed

+27
-11
lines changed

6 files changed

+27
-11
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"@actions/github": "6.0.1",
2323
"nano-spawn": "2.0.0",
2424
"node-style-text": "^2.1.2",
25+
"outdent": "^0.8.0",
2526
"pretty-ms": "9.3.0"
2627
},
2728
"devDependencies": {
@@ -33,7 +34,6 @@
3334
"eslint-config-prettier": "10.1.8",
3435
"globals": "16.5.0",
3536
"npm-run-all": "4.1.5",
36-
"outdent": "0.8.0",
3737
"prettier": "3.7.4",
3838
"typescript": "5.9.3",
3939
"typescript-eslint": "8.49.0",

src/execute-command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export async function executeCommand(commandString: string) {
2929
const results = await Promise.allSettled(
3030
repositories.map(async (repository) => {
3131
try {
32-
return runPrettier(repository, {
32+
return await runPrettier(repository, {
3333
cwd: directory,
3434
alternative: alternativePrettier,
3535
original: originalPrettier,

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ async function run() {
2222
}
2323

2424
await logger.brief(
25-
`Received with command '${commandString}', start execute ...`,
25+
`Received with command \`${commandString}\`, start execute ...`,
2626
);
2727

2828
const commandExecuteResult = await executeCommand(commandString);

src/logger.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { IS_GITHUB_ACTION, GITHUB_ACTION_JOB_URL } from "./constants.ts";
33
import { getOctokit } from "./octokit.ts";
44
import { codeBlock } from "./utilities.ts";
55
import { inspect } from "node:util";
6+
import { outdent } from "outdent";
67

78
type Comment = Awaited<ReturnType<typeof createComment>>;
89

@@ -27,14 +28,20 @@ async function updateComment(body: string, comment: Comment) {
2728
}
2829

2930
let briefCommentRequest: ReturnType<typeof createComment> | undefined;
30-
export async function brief(body: string) {
31-
console.log(body);
31+
const messages: { time: Date; message: string }[] = [];
32+
export async function brief(message: string) {
33+
console.log(message);
3234

3335
if (!IS_GITHUB_ACTION) {
3436
return;
3537
}
3638

37-
body += `\n__[details](${GITHUB_ACTION_JOB_URL})__`;
39+
messages.push({ time: new Date(), message });
40+
41+
const body = outdent`
42+
${messages.map(({ time, message }) => `[${time}}]: ${message}]`).join("\n\n")}
43+
__[details](${GITHUB_ACTION_JOB_URL})__
44+
`;
3845

3946
if (briefCommentRequest) {
4047
const comment = await briefCommentRequest;
@@ -55,10 +62,11 @@ export async function error(error: Error) {
5562
return;
5663
}
5764

58-
const text = `
59-
## [${error.name}]
65+
const text = outdent`
66+
<details><summary>[${error.name}](${error.message})</summary>
6067
6168
${codeBlock(inspect(error))}
69+
</details>
6270
`;
6371
return await brief(text);
6472
}

src/report.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { PRETTIER_PACKAGE_TYPE_PULL_REQUEST } from "./parse-command.ts";
22
import { type PrettierVersion } from "./parse-command.ts";
33
import { type ExecuteCommandResult } from "./execute-command.ts";
44
import { codeBlock } from "./utilities.ts";
5+
import { outdent } from "outdent";
56

67
function getPrettierVersionDescription(prettier: PrettierVersion) {
78
if (prettier.type === PRETTIER_PACKAGE_TYPE_PULL_REQUEST) {
@@ -77,6 +78,13 @@ function formatDiff(diff: string) {
7778
const linesCount = diff.split("\n").length;
7879
const code = codeBlock(diff, "diff");
7980
return linesCount > LONG_DIFF_THRESHOLD_IN_LINES
80-
? `<details><summary>Diff (${linesCount} lines)</summary>\n\n${code}\n\n</details>`
81+
? outdent`
82+
<details>
83+
<summary>Diff (${linesCount} lines)</summary>
84+
85+
${code}
86+
87+
</details>
88+
`
8189
: code;
8290
}

yarn.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2514,7 +2514,7 @@ __metadata:
25142514
languageName: node
25152515
linkType: hard
25162516

2517-
"outdent@npm:0.8.0":
2517+
"outdent@npm:^0.8.0":
25182518
version: 0.8.0
25192519
resolution: "outdent@npm:0.8.0"
25202520
checksum: 10c0/d8a6c38b838b7ac23ebf1cc50442312f4efe286b211dbe5c71fa84d5daa2512fb94a8f2df1389313465acb0b4e5fa72270dd78f519f3d4db5bc22b2762c86827
@@ -2696,7 +2696,7 @@ __metadata:
26962696
nano-spawn: "npm:2.0.0"
26972697
node-style-text: "npm:^2.1.2"
26982698
npm-run-all: "npm:4.1.5"
2699-
outdent: "npm:0.8.0"
2699+
outdent: "npm:^0.8.0"
27002700
prettier: "npm:3.7.4"
27012701
pretty-ms: "npm:9.3.0"
27022702
typescript: "npm:5.9.3"

0 commit comments

Comments
 (0)