fix(SmartFsProviderNode): Fix Node provider watch path handling and remove main test entry
This commit is contained in:
@@ -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'
|
||||
}
|
||||
|
||||
@@ -266,6 +266,10 @@ export class SmartFsProviderNode implements ISmartFsProvider {
|
||||
// --- Watch Operations ---
|
||||
|
||||
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(
|
||||
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)) {
|
||||
|
||||
Reference in New Issue
Block a user