| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent fd74eef commit c63e00e
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -157,7 +157,9 @@ class FSWatcher extends EventEmitter { | |||
| 157 | 157 | } | |
| 158 | 158 | } | |
| 159 | 159 | } catch (error) { | |
| 160 | - this.emit('error', error); | ||
| 160 | + if (error.code !== 'ENOENT') { | ||
| 161 | + this.emit('error', error); | ||
| 162 | + } | ||
| 161 | 163 | } | |
| 162 | 164 | } | |
| 163 | 165 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,44 @@ | |||
| 1 | + // Flags: --expose-internals | ||
| 2 | + 'use strict'; | ||
| 3 | + | ||
| 4 | + const common = require('../common'); | ||
| 5 | + const tmpdir = require('../common/tmpdir'); | ||
| 6 | + const assert = require('assert'); | ||
| 7 | + const fs = require('fs'); | ||
| 8 | + const path = require('path'); | ||
| 9 | + const { kFSWatchStart } = require('internal/fs/watchers'); | ||
| 10 | + const { FSWatcher } = require('internal/fs/recursive_watch'); | ||
| 11 | + | ||
| 12 | + if (common.isIBMi) | ||
| 13 | + common.skip('IBMi does not support `fs.watch()`'); | ||
| 14 | + | ||
| 15 | + tmpdir.refresh(); | ||
| 16 | + | ||
| 17 | + const parent = tmpdir.resolve('parent'); | ||
| 18 | + const child = path.join(parent, 'child'); | ||
| 19 | + fs.mkdirSync(child, { recursive: true }); | ||
| 20 | + fs.writeFileSync(path.join(child, 'test.tmp'), 'test'); | ||
| 21 | + | ||
| 22 | + const watch = fs.watch; | ||
| 23 | + let deletedChild = false; | ||
| 24 | + fs.watch = function(filename, ...args) { | ||
| 25 | + const watcher = Reflect.apply(watch, this, [filename, ...args]); | ||
| 26 | + | ||
| 27 | + if (filename === child) { | ||
| 28 | + fs.rmSync(child, { recursive: true }); | ||
| 29 | + deletedChild = true; | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + return watcher; | ||
| 33 | + }; | ||
| 34 | + | ||
| 35 | + const watcher = new FSWatcher({ recursive: true }); | ||
| 36 | + watcher.on('error', common.mustNotCall()); | ||
| 37 | + | ||
| 38 | + try { | ||
| 39 | + watcher[kFSWatchStart](parent); | ||
| 40 | + assert.strictEqual(deletedChild, true); | ||
| 41 | + } finally { | ||
| 42 | + watcher.close(); | ||
| 43 | + fs.watch = watch; | ||
| 44 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments