From 6308e198c7b9f3332bf9bb1d19653c67cef766a7 Mon Sep 17 00:00:00 2001 From: Juergen Kunz Date: Sat, 29 Nov 2025 21:01:51 +0000 Subject: [PATCH] fix(SmartFsProviderNode): Fix Node provider watch path handling and remove main test entry --- changelog.md | 7 +++++++ test/test.ts | 7 ------- ts/00_commitinfo_data.ts | 2 +- ts/providers/smartfs.provider.node.ts | 7 ++++++- 4 files changed, 14 insertions(+), 9 deletions(-) delete mode 100644 test/test.ts diff --git a/changelog.md b/changelog.md index adc97b0..0a1db66 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,12 @@ # Changelog +## 2025-11-29 - 1.1.2 - fix(SmartFsProviderNode) +Fix Node provider watch path handling and remove main test entry + +- Node provider: detect at start whether the watched path is a file or directory (fs.stat) and build fullPath accordingly so watching a single file does not incorrectly join the filename onto the file path. +- Watch callback: ensure events are evaluated against the configured filter using the correct full path. +- Tests: removed test/test.ts (main test entry that previously imported provider test files). + ## 2025-11-29 - 1.1.1 - fix(smartfs.provider.node) Default deleteDirectory to recursive=true in Node provider diff --git a/test/test.ts b/test/test.ts deleted file mode 100644 index 97493cb..0000000 --- a/test/test.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Main test entry point - * Imports all test files - */ - -import './test.memory.provider.js'; -import './test.node.provider.js'; diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index d130f5e..627e9ac 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@push.rocks/smartfs', - version: '1.1.1', + version: '1.1.2', description: 'a cross platform extendable fs module' } diff --git a/ts/providers/smartfs.provider.node.ts b/ts/providers/smartfs.provider.node.ts index e3aae95..2957f46 100644 --- a/ts/providers/smartfs.provider.node.ts +++ b/ts/providers/smartfs.provider.node.ts @@ -266,6 +266,10 @@ export class SmartFsProviderNode implements ISmartFsProvider { // --- Watch Operations --- public async watch(path: string, callback: TWatchCallback, options?: IWatchOptions): Promise { + // Check once at start if we're watching a file or directory + const watchedStats = await fs.stat(path); + const isWatchingFile = watchedStats.isFile(); + const watcher = fsSync.watch( path, { @@ -274,7 +278,8 @@ export class SmartFsProviderNode implements ISmartFsProvider { async (eventType, filename) => { if (!filename) return; - const fullPath = pathModule.join(path, filename); + // For file watching, path IS the file; for directory, join with filename + const fullPath = isWatchingFile ? path : pathModule.join(path, filename); // Apply filter if (options?.filter && !this.matchesPathFilter(fullPath, options.filter)) {