Skip to content

Commit cd6cc48

Browse files
committed
fix: Add validation to check if source file exists before reading it
This change adds a check to ensure that the source file exists before attempting to read it. This prevents the code from crashing when attempting to read non-existent files.
1 parent ec6adfb commit cd6cc48

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,9 @@ async function runSources() {
199199
let entry = /{{\s*([\w\W]+)\s*}}/g.exec(variable);
200200
entry = entry[1].trim()
201201
if (entry) {
202+
if (!fs.existsSync(entry))
203+
continue
204+
202205
let read_type = 'utf8'
203206
let mime_type = mime.lookup(entry) || 'text/html';
204207
if (/^(image|audio|video)\/[-+.\w]+/.test(mime_type)) {

0 commit comments

Comments
 (0)