Skip to content

Commit

Permalink
fix: Skip writing when the ci process cannot read the subpackages dir…
Browse files Browse the repository at this point in the history
…ectory.
  • Loading branch information
zrwusa committed Nov 22, 2024
1 parent c3122e7 commit e4ebf5f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions scripts/testToExample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,14 @@ function updateExamples(testDir: string, sourceBaseDir: string): void {
* Replace content between markers in README.md.
*/
function replaceExamplesInReadme(readmePath: string, newExamples: string[]): void {
const readmeContent = fs.readFileSync(readmePath, 'utf-8');
let readmeContent: string;

try {
readmeContent = fs.readFileSync(readmePath, 'utf-8');
} catch (error) {
console.warn(`Failed to read ${fileName} at ${readmePath}: ${error}`);
return;
}

const startIdx = readmeContent.indexOf(START_MARKER);
const endIdx = readmeContent.indexOf(END_MARKER);
Expand All @@ -269,7 +276,7 @@ function replaceExamplesInReadme(readmePath: string, newExamples: string[]): voi
const updatedContent = `${before}\n\n${newExamples.join('\n\n')}\n\n${after}`;
fs.writeFileSync(readmePath, updatedContent, 'utf-8');

console.log(`README.md updated with new examples.`);
console.log(`${fileName} updated with new examples.`);
}

// Run the script
Expand Down

0 comments on commit e4ebf5f

Please sign in to comment.