Skip to content

Commit d97e4d9

Browse files
authored
fix: prevent build failure due to cache files (#310)
1 parent 507e887 commit d97e4d9

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

scripts/create-common-bundle/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import glob from 'tiny-glob/sync.js';
55
import { fileURLToPath } from 'url';
66
import { execSync } from 'child_process';
77

8+
if (!!process.env.VERCEL) {
9+
execSync('git clean -d -f content/tutorial');
10+
}
11+
812
const cwd = 'content/tutorial/common';
913

1014
execSync('npm ci', { cwd });

src/lib/server/content.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ function is_valid(dir) {
2929
return /^\d{2}-/.test(dir);
3030
}
3131

32+
/**
33+
* @param {string} part
34+
* @param {string} chapter
35+
* @param {string} dir
36+
*/
37+
function exists_readme(part, chapter, dir) {
38+
return fs.existsSync(`content/tutorial/${part}/${chapter}/${dir}/README.md`);
39+
}
40+
3241
/**
3342
* @returns {import('$lib/types').PartStub[]}
3443
*/
@@ -44,7 +53,7 @@ export function get_index() {
4453
chapters: chapters.map((chapter) => {
4554
const exercises = fs
4655
.readdirSync(`content/tutorial/${part}/${chapter}`)
47-
.filter(is_valid)
56+
.filter((dir) => is_valid(dir) && exists_readme(part, chapter, dir))
4857
.map(posixify);
4958

5059
return {

0 commit comments

Comments
 (0)