Skip to content

Commit 64884c2

Browse files
author
Chris Young
committed
test: fs.watch filename check for Windows & AIX
Fixes: nodejs#13108
1 parent 9bd4012 commit 64884c2

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

doc/api/fs.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2406,7 +2406,7 @@ this improves the usability of file watching. This is expected behavior.
24062406
<!--type=misc-->
24072407

24082408
Providing `filename` argument in the callback is only supported on Linux,
2409-
macOS, and Windows. Even on supported platforms, `filename` is not always
2409+
macOS, Windows, and AIX. Even on supported platforms, `filename` is not always
24102410
guaranteed to be provided. Therefore, don't assume that `filename` argument is
24112411
always provided in the callback, and have some fallback logic if it is null.
24122412

test/parallel/test-fs-watchfile.js

+5-9
Original file line numberDiff line numberDiff line change
@@ -64,24 +64,20 @@ fs.watchFile(enoentFile, {interval: 0}, common.mustCall(function(curr, prev) {
6464
}
6565
}, 2));
6666

67-
// Watch events should callback with a filename
68-
if (common.isLinux || common.isOSX) {
67+
// Watch events should callback with a filename on supported systems
68+
if (common.isLinux || common.isOSX || common.isWindows || common.isAix) {
6969
const dir = common.tmpDir + '/watch';
7070

7171
fs.mkdir(dir, common.mustCall(function(err) {
72-
assert(!err);
72+
if (err) assert.fail(err);
7373

7474
fs.watch(dir, common.mustCall(function(eventType, filename) {
7575
this._handle.close();
76-
common.refreshTmpDir();
7776
assert.strictEqual(filename, 'foo.txt');
7877
}));
7978

80-
fs.writeFile(`${dir}/foo.txt`, 'foo', common.mustCall((err) => {
81-
if (err) {
82-
common.refreshTmpDir();
83-
assert(!err);
84-
}
79+
fs.writeFile(`${dir}/foo.txt`, 'foo', common.mustCall(function(err) {
80+
if (err) assert.fail(err);
8581
}));
8682
}));
8783
}

0 commit comments

Comments
 (0)