-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsummary.ts
65 lines (65 loc) · 1.91 KB
/
summary.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import {
clearFileCommand,
getFileCommandPath
} from "./command/file.ts";
/**
* Append data to the summary.
*
* > **🛡️ Runtime Permissions**
* >
* > - Environment Variable \[Deno: `env`\]
* > - `GITHUB_STEP_SUMMARY`
* > - File System - Read \[Deno: `read`; NodeJS (>= v20.9.0) 🧪: `fs-read`\]
* > - *Resources*
* > - File System - Write \[Deno: `write`; NodeJS (>= v20.9.0) 🧪: `fs-write`\]
* > - *Resources*
* @param {string | Uint8Array} data Data.
* @returns {void}
*/
export function appendSummary(data: string | Uint8Array): void {
const path: string = getFileCommandPath("GITHUB_STEP_SUMMARY");
if (typeof data === "string") {
Deno.writeTextFileSync(path, data, { append: true });
} else {
Deno.writeFileSync(path, data, { append: true });
}
}
/**
* Clear the summary which set in the current step.
*
* > **🛡️ Runtime Permissions**
* >
* > - Environment Variable \[Deno: `env`\]
* > - `GITHUB_STEP_SUMMARY`
* > - File System - Read \[Deno: `read`; NodeJS (>= v20.9.0) 🧪: `fs-read`\]
* > - *Resources*
* > - File System - Write \[Deno: `write`; NodeJS (>= v20.9.0) 🧪: `fs-write`\]
* > - *Resources*
* @returns {void}
*/
export function clearSummary(): void {
return clearFileCommand("GITHUB_STEP_SUMMARY");
}
/**
* Get the size of the summary which set in the current step.
*
* > **🛡️ Runtime Permissions**
* >
* > - Environment Variable \[Deno: `env`\]
* > - `GITHUB_STEP_SUMMARY`
* > - File System - Read \[Deno: `read`; NodeJS (>= v20.9.0) 🧪: `fs-read`\]
* > - *Resources*
* > - File System - Write \[Deno: `write`; NodeJS (>= v20.9.0) 🧪: `fs-write`\]
* > - *Resources*
* @returns {number} Size of the summary, in bytes.
*/
export function getSummarySize(): number {
try {
return Deno.statSync(getFileCommandPath("GITHUB_STEP_SUMMARY")).size;
} catch (error) {
if (error instanceof Deno.errors.NotFound) {
return 0;
}
throw error;
}
}