- Move external URL checks to its own module under `tests/`. This separates them from integration test, addressing long runs and frequent failures that led to ignoring test results. - Move `check-desktop-runtime-errors` to `tests/checks` to keep all test-related checks into one directory. - Replace `ts-node` with `vite` for running `check-desktop-runtime-errors` to maintain a consistent execution environment across checks. - Implement a timeout for each fetch call. - Be nice to external sources, wait 5 seconds before sending another request to an URL under same domain. This solves rate-limiting issues. - Instead of running test on every push/pull request, run them only weekly. - Do not run tests on each commit/PR but only scheduled (weekly) to minimize noise. - Fix URLs are not captured correctly inside backticks or parenthesis.
23 lines
543 B
TypeScript
23 lines
543 B
TypeScript
export function indentText(
|
|
text: string,
|
|
indentLevel = 1,
|
|
): string {
|
|
validateText(text);
|
|
const indentation = '\t'.repeat(indentLevel);
|
|
return splitTextIntoLines(text)
|
|
.map((line) => (line ? `${indentation}${line}` : line))
|
|
.join('\n');
|
|
}
|
|
|
|
export function splitTextIntoLines(text: string): string[] {
|
|
validateText(text);
|
|
return text
|
|
.split(/[\r\n]+/);
|
|
}
|
|
|
|
function validateText(text: string): void {
|
|
if (typeof text !== 'string') {
|
|
throw new Error(`text is not a string. It is: ${typeof text}\n${text}`);
|
|
}
|
|
}
|