refactor(scripts): cleanup & enforce code style (#1388)
This commit is contained in:
1 parent
7db9b234c1
commit
5d74d700a2
23 files changed
+290
-270
No files matched your search
+11
-14
@@ -1,15 +1,14 @@
|
||||
export const updateFile = (
|
||||
export function writeWithPreamble(
|
||||
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);
|
||||
};
|
||||
) {
|
||||
return Deno.writeTextFile(
|
||||
filePath,
|
||||
"# THIS FILE IS AUTOGENERATED. DO NOT EDIT IT BY HAND.\n" + fileContent,
|
||||
);
|
||||
}
|
||||
|
||||
export const updateReadme = ({
|
||||
export function updateReadme({
|
||||
readme,
|
||||
section,
|
||||
newContent,
|
||||
@@ -17,20 +16,18 @@ export const updateReadme = ({
|
||||
readme: string;
|
||||
section: string;
|
||||
newContent: string;
|
||||
}): 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))
|
||||
) {
|
||||
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;
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user