Skip to content

Commit 5e71831

Browse files
committed
refactor(tools): extract function for basicEnvVars docs
As we'll be adding more functionality into this file, and extracting the function helps keep it clearer what's being done in the function scope.
1 parent 1ca1802 commit 5e71831

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

tools/docs/env-vars.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,21 @@ import { basicEnvVars } from '../../lib/util/exec/env.ts';
22
import { readFile, updateFile } from '../utils/index.ts';
33
import { replaceContent } from './utils.ts';
44

5-
export async function generateEnvVars(dist: string): Promise<void> {
5+
function basicEnvVarsToMarkdown(): string {
66
const list = [...basicEnvVars]
77
// case-insensitive sort
88
.sort((a, b) => a.localeCompare(b, undefined, { sensitivity: 'base' }))
99
.map((v) => ` - \`${v}\``)
1010
.join('\n');
11-
const txt = `${list}\n\n`;
11+
return `${list}\n\n`;
12+
}
1213

14+
export async function generateEnvVars(dist: string): Promise<void> {
1315
let content = await readFile('docs/usage/environment-variable-handling.md');
14-
content = replaceContent(content, txt, '<!-- Autogenerate basicEnvVars -->');
16+
content = replaceContent(
17+
content,
18+
basicEnvVarsToMarkdown(),
19+
'<!-- Autogenerate basicEnvVars -->',
20+
);
1521
await updateFile(`${dist}/environment-variable-handling.md`, content);
1622
}

0 commit comments

Comments
 (0)