Skip to content

Commit 4339fdf

Browse files
committed
fix: github code blocks formatter
1 parent 6c864a7 commit 4339fdf

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/formatters.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import fs from "fs";
22

33
export function formatFileContent(file: string) {
4-
let content = fs.readFileSync(file, "utf8");
5-
6-
addGitHubCodeBlocks(content);
7-
8-
fs.writeFileSync(file, content);
4+
addGitHubCodeBlocks(file);
95
}
106

11-
function addGitHubCodeBlocks(content: string) {
7+
function addGitHubCodeBlocks(file: string) {
8+
let content = fs.readFileSync(file, "utf8");
9+
1210
const ghBlobUrlRegex =
1311
/https:\/\/github\.com\/[A-Za-z]+\/([A-Za-z]+(-[A-Za-z]+)+)\/blob\/[A-Za-z0-9]+\/([A-Za-z]+(\/[A-Za-z]+)+)\.[A-Za-z]+#L[0-9]+-L[0-9]+/g;
1412

@@ -24,4 +22,6 @@ function addGitHubCodeBlocks(content: string) {
2422

2523
content = content.replace(url, codeBlockForUrl);
2624
}
25+
26+
fs.writeFileSync(file, content);
2727
}

0 commit comments

Comments
 (0)