Commit 98ce638
committed
fix(build): correct writeFileSync usage; harden is-client SSR check; minor cleanup
- src/scripts/build-content-tree.mjs: replace incorrect fs.writeFileSync callback
with try/catch. The synchronous API does not accept a callback; passing one
throws a TypeError and breaks `npm run content`. Now the script logs success
and sets a non‑zero exit code on failure.
- src/utilities/is-client.js: avoid ReferenceError in non‑browser contexts by
guarding with `typeof window !== 'undefined'` and switch to a consistent ESM
default export. This prevents crashes during SSR/SSG or tooling that evaluates
the module outside the browser.
- src/utilities/flatten-content-tree.mjs: use `forEach` instead of `map` when
not using the returned array. This clarifies intent and avoids linter warnings
about the unused result of `map`.
These changes are internal, do not alter runtime behavior of the website, and
improve correctness, stability, and readability.
Signed-off-by: shubham shukla <shubhushukla586@gmail.com>1 parent 0dac331 commit 98ce638
File tree
3 files changed
+21
-15
lines changed- src
- scripts
- utilities
3 files changed
+21
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
55 | 56 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
2 | 5 | | |
3 | | - | |
| 6 | + | |
0 commit comments