| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e6a1896 commit 5f1a59c
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,7 +28,7 @@ if (common.isIBMi) { | |||
| 28 | 28 | ||
| 29 | 29 | const path = require('path'); | |
| 30 | 30 | const fs = require('fs'); | |
| 31 | - | ||
| 31 | + const assert = require('assert'); | ||
| 32 | 32 | const tmpdir = require('../common/tmpdir'); | |
| 33 | 33 | tmpdir.refresh(); | |
| 34 | 34 | ||
@@ -38,13 +38,14 @@ const filepath = path.join(testsubdir, 'watch.txt'); | |||
| 38 | 38 | ||
| 39 | 39 | fs.mkdirSync(testsubdir, 0o700); | |
| 40 | 40 | ||
| 41 | - // Need a grace period, else the mkdirSync() above fires off an event. | ||
| 42 | - setTimeout(function() { | ||
| 43 | - const watcher = fs.watch(testDir, { persistent: true }, common.mustNotCall()); | ||
| 44 | - setTimeout(function() { | ||
| 45 | - fs.writeFileSync(filepath, 'test'); | ||
| 46 | - }, 100); | ||
| 47 | - setTimeout(function() { | ||
| 48 | - watcher.close(); | ||
| 49 | - }, 500); | ||
| 50 | - }, 50); | ||
| 41 | + const watcher = fs.watch(testDir, { persistent: true }, (event, filename) => { | ||
| 42 | + // This function may be called with the directory depending on timing but | ||
| 43 | + // must not be called with the file.. | ||
| 44 | + assert.strictEqual(filename, 'testsubdir'); | ||
| 45 | + }); | ||
| 46 | + setTimeout(() => { | ||
| 47 | + fs.writeFileSync(filepath, 'test'); | ||
| 48 | + }, 100); | ||
| 49 | + setTimeout(() => { | ||
| 50 | + watcher.close(); | ||
| 51 | + }, 500); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments