Skip to content

Commit 96b0e83

Browse files
committed
chore: format
1 parent f6d1268 commit 96b0e83

File tree

2 files changed

+42
-36
lines changed

2 files changed

+42
-36
lines changed

scripts/utils/color.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
export let colors = {
22
// Regular colors
3-
black: '\x1b[30m',
4-
red: '\x1b[31m',
5-
green: '\x1b[32m',
6-
yellow: '\x1b[33m',
7-
blue: '\x1b[34m',
8-
magenta: '\x1b[35m',
9-
cyan: '\x1b[36m',
10-
white: '\x1b[37m',
3+
black: "\x1b[30m",
4+
red: "\x1b[31m",
5+
green: "\x1b[32m",
6+
yellow: "\x1b[33m",
7+
blue: "\x1b[34m",
8+
magenta: "\x1b[35m",
9+
cyan: "\x1b[36m",
10+
white: "\x1b[37m",
1111

1212
// Bright colors
13-
gray: '\x1b[90m',
14-
lightRed: '\x1b[91m',
15-
lightGreen: '\x1b[92m',
16-
lightYellow: '\x1b[93m',
17-
lightBlue: '\x1b[94m',
18-
lightMagenta: '\x1b[95m',
19-
lightCyan: '\x1b[96m',
20-
lightWhite: '\x1b[97m',
13+
gray: "\x1b[90m",
14+
lightRed: "\x1b[91m",
15+
lightGreen: "\x1b[92m",
16+
lightYellow: "\x1b[93m",
17+
lightBlue: "\x1b[94m",
18+
lightMagenta: "\x1b[95m",
19+
lightCyan: "\x1b[96m",
20+
lightWhite: "\x1b[97m",
2121

2222
// Styles
23-
bold: '\x1b[1m',
24-
dim: '\x1b[2m',
25-
underline: '\x1b[4m',
23+
bold: "\x1b[1m",
24+
dim: "\x1b[2m",
25+
underline: "\x1b[4m",
2626

27-
reset: '\x1b[0m',
28-
}
27+
reset: "\x1b[0m",
28+
};
2929

3030
export function colorize(text: string, color: string): string {
3131
if (process.env.NO_COLOR) {
32-
return text
32+
return text;
3333
}
34-
return `${color}${text}${colors.reset}`
34+
return `${color}${text}${colors.reset}`;
3535
}

scripts/utils/fs.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,42 @@
1-
import * as fs from 'node:fs'
1+
import * as fs from "node:fs";
22

33
export function fileExists(filename: string): boolean {
4-
return fs.existsSync(filename)
4+
return fs.existsSync(filename);
55
}
66

7-
export function readFile(filename: string, encoding: BufferEncoding = 'utf-8'): string {
7+
export function readFile(
8+
filename: string,
9+
encoding: BufferEncoding = "utf-8",
10+
): string {
811
try {
9-
return fs.readFileSync(filename, encoding)
12+
return fs.readFileSync(filename, encoding);
1013
} catch (error) {
11-
if (isFsError(error) && error.code === 'ENOENT') {
12-
console.error(`Not found: "${filename}"`)
13-
process.exit(1)
14+
if (isFsError(error) && error.code === "ENOENT") {
15+
console.error(`Not found: "${filename}"`);
16+
process.exit(1);
1417
} else {
15-
throw error
18+
throw error;
1619
}
1720
}
1821
}
1922

2023
function isFsError(error: unknown): error is { code: string } {
2124
return (
22-
typeof error === 'object' && error != null && 'code' in error && typeof error.code === 'string'
23-
)
25+
typeof error === "object" &&
26+
error != null &&
27+
"code" in error &&
28+
typeof error.code === "string"
29+
);
2430
}
2531

2632
export function writeFile(filename: string, data: string): void {
27-
fs.writeFileSync(filename, data)
33+
fs.writeFileSync(filename, data);
2834
}
2935

3036
export function readJson(filename: string): any {
31-
return JSON.parse(readFile(filename))
37+
return JSON.parse(readFile(filename));
3238
}
3339

3440
export function writeJson(filename: string, data: any): void {
35-
writeFile(filename, JSON.stringify(data, null, 2) + '\n')
41+
writeFile(filename, JSON.stringify(data, null, 2) + "\n");
3642
}

0 commit comments

Comments
 (0)