fix(SmartFsProviderNode): Fix Node provider watch path handling and remove main test entry
This commit is contained in:
@@ -1,5 +1,12 @@
|
|||||||
# Changelog
|
# 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)
|
## 2025-11-29 - 1.1.1 - fix(smartfs.provider.node)
|
||||||
Default deleteDirectory to recursive=true in Node provider
|
Default deleteDirectory to recursive=true in Node provider
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
/**
|
|
||||||
* Main test entry point
|
|
||||||
* Imports all test files
|
|
||||||
*/
|
|
||||||
|
|
||||||
import './test.memory.provider.js';
|
|
||||||
import './test.node.provider.js';
|
|
||||||
@@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/smartfs',
|
name: '@push.rocks/smartfs',
|
||||||
version: '1.1.1',
|
version: '1.1.2',
|
||||||
description: 'a cross platform extendable fs module'
|
description: 'a cross platform extendable fs module'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -266,6 +266,10 @@ export class SmartFsProviderNode implements ISmartFsProvider {
|
|||||||
// --- Watch Operations ---
|
// --- Watch Operations ---
|
||||||
|
|
||||||
public async watch(path: string, callback: TWatchCallback, options?: IWatchOptions): Promise<IWatcherHandle> {
|
public async watch(path: string, callback: TWatchCallback, options?: IWatchOptions): Promise<IWatcherHandle> {
|
||||||
|
// 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(
|
const watcher = fsSync.watch(
|
||||||
path,
|
path,
|
||||||
{
|
{
|
||||||
@@ -274,7 +278,8 @@ export class SmartFsProviderNode implements ISmartFsProvider {
|
|||||||
async (eventType, filename) => {
|
async (eventType, filename) => {
|
||||||
if (!filename) return;
|
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
|
// Apply filter
|
||||||
if (options?.filter && !this.matchesPathFilter(fullPath, options.filter)) {
|
if (options?.filter && !this.matchesPathFilter(fullPath, options.filter)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user