From 632c70fc90b261499fbe65716006220584cddb4e Mon Sep 17 00:00:00 2001 From: Benjamin Toby Date: Sat, 21 Mar 2026 14:58:41 +0100 Subject: [PATCH] Update watcher function. Add .css files to the rebuild pipeline --- dist/functions/server/watcher.js | 8 +++++--- package.json | 2 +- src/functions/server/watcher.ts | 12 +++++++++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/dist/functions/server/watcher.js b/dist/functions/server/watcher.js index c96f1b1..795d900 100644 --- a/dist/functions/server/watcher.js +++ b/dist/functions/server/watcher.js @@ -30,10 +30,11 @@ export default function watcher() { } return; } - if (!filename.match(target_files_match)) { + const is_file_of_interest = Boolean(filename.match(target_files_match)); + if (!is_file_of_interest) { return; } - if (!filename.match(/^src\/pages\//)) + if (!filename.match(/^src\/pages\/|\.css$/)) return; if (filename.match(/\/(--|\()/)) return; @@ -41,8 +42,9 @@ export default function watcher() { return; const fullPath = path.join(ROOT_DIR, filename); const action = existsSync(fullPath) ? "created" : "deleted"; + const type = filename.match(/\.css$/) ? "Sylesheet" : "Page"; await fullRebuild({ - msg: `Page ${action}: ${filename}. Rebuilding ...`, + msg: `${type} ${action}: ${filename}. Rebuilding ...`, }); }); global.PAGES_SRC_WATCHER = pages_src_watcher; diff --git a/package.json b/package.json index 90e6158..642fa20 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ ], "scripts": { "dev": "tsc --watch", - "git:push": "tsc --noEmit && tsc && git add . && git commit -m 'Update README.md' && git push", + "git:push": "tsc --noEmit && tsc && git add . && git commit -m 'Update watcher function. Add .css files to the rebuild pipeline' && git push", "compile": "bun build ./src/commands/index.ts --compile --outfile bin/bunext", "build": "tsc", "test": "bun test --max-concurrency=1" diff --git a/src/functions/server/watcher.ts b/src/functions/server/watcher.ts index bab16a6..53693c1 100644 --- a/src/functions/server/watcher.ts +++ b/src/functions/server/watcher.ts @@ -15,6 +15,7 @@ export default function watcher() { }, async (event, filename) => { if (!filename) return; + const excluded_match = /node_modules\/|^public\/|^\.bunext\/|^\.git\/|^dist\/|bun\.lockb$/; @@ -38,20 +39,25 @@ export default function watcher() { return; } - if (!filename.match(target_files_match)) { + const is_file_of_interest = Boolean( + filename.match(target_files_match), + ); + + if (!is_file_of_interest) { return; } - if (!filename.match(/^src\/pages\//)) return; + if (!filename.match(/^src\/pages\/|\.css$/)) return; if (filename.match(/\/(--|\()/)) return; if (global.RECOMPILING) return; const fullPath = path.join(ROOT_DIR, filename); const action = existsSync(fullPath) ? "created" : "deleted"; + const type = filename.match(/\.css$/) ? "Sylesheet" : "Page"; await fullRebuild({ - msg: `Page ${action}: ${filename}. Rebuilding ...`, + msg: `${type} ${action}: ${filename}. Rebuilding ...`, }); }, );