forked from catppuccin/userstyles
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.ts
More file actions
36 lines (33 loc) 路 977 Bytes
/
Copy pathutils.ts
File metadata and controls
36 lines (33 loc) 路 977 Bytes
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
export const updateFile = (
filePath: string,
fileContent: string,
comment = true,
) => {
const preamble = comment
? "# THIS FILE IS AUTOGENERATED. DO NOT EDIT IT BY HAND.\n"
: "";
return Deno.writeTextFile(filePath, preamble + fileContent);
};
export const updateReadme = ({
readme,
section,
newContent,
}: {
readme: string;
section: string;
newContent: string;
}): string => {
const preamble =
"<!-- the following section is auto-generated, do not edit -->";
const startMarker = `<!-- AUTOGEN:${section.toUpperCase()} START -->`;
const endMarker = `<!-- AUTOGEN:${section.toUpperCase()} END -->`;
const wrapped = `${startMarker}\n${preamble}\n${newContent}\n${endMarker}`;
if (
!(readme.includes(startMarker) && readme.includes(endMarker))
) {
throw new Error("Markers not found in README.md");
}
const pre = readme.split(startMarker)[0];
const end = readme.split(endMarker)[1];
return pre + wrapped + end;
};