Skip to content

Commit f568187

Browse files
committed
preview watcher: filter inputs by existence before reading them
1 parent e1c02c3 commit f568187

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/project/serve/watch.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,15 @@ export function watchProject(
115115
if (options[kProjectWatchInputs]) {
116116
// get inputs (filter by whether the last time we rendered
117117
// this input had the exact same content hash)
118-
const inputs = paths.filter(isInputFile).filter((input) => {
119-
return !rendered.has(input) ||
120-
rendered.get(input) !== md5Hash(Deno.readTextFileSync(input));
121-
});
118+
const inputs = paths.filter(isInputFile).filter(existsSync).filter(
119+
(input) => {
120+
return !rendered.has(input) ||
121+
rendered.get(input) !== md5Hash(Deno.readTextFileSync(input));
122+
},
123+
);
122124
if (inputs.length) {
123125
// record rendered time
124-
for (const input of inputs) {
126+
for (const input of inputs.filter(existsSync)) {
125127
rendered.set(input, md5Hash(Deno.readTextFileSync(input)));
126128
}
127129
// render

0 commit comments

Comments
 (0)