mirror of
https://github.com/nodejs/node.git
synced 2025-04-30 23:56:58 +00:00

Signed-off-by: Matteo Collina <hello@matteocollina.com> PR-URL: https://github.com/nodejs/node/pull/51406 Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
36 lines
1.0 KiB
JavaScript
36 lines
1.0 KiB
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const { watch, writeFileSync } = require('node:fs');
|
|
const { join } = require('node:path');
|
|
const tmpdir = require('../common/tmpdir.js');
|
|
const assert = require('assert');
|
|
|
|
if (common.isIBMi)
|
|
common.skip('IBMi does not support `fs.watch()`');
|
|
|
|
// fs-watch on folders have limited capability in AIX.
|
|
// The testcase makes use of folder watching, and causes
|
|
// hang. This behavior is documented. Skip this for AIX.
|
|
|
|
if (common.isAIX)
|
|
common.skip('folder watch capability is limited in AIX.');
|
|
|
|
tmpdir.refresh();
|
|
|
|
const tmpDir = tmpdir.path;
|
|
const filename = join(tmpDir, 'test.file');
|
|
|
|
const keepalive = setTimeout(() => {
|
|
throw new Error('timed out');
|
|
}, common.platformTimeout(30_000));
|
|
|
|
const watcher = watch(tmpDir, { recursive: true }, common.mustCall((eventType, _filename) => {
|
|
clearTimeout(keepalive);
|
|
watcher.close();
|
|
assert.strictEqual(eventType, 'rename');
|
|
assert.strictEqual(join(tmpDir, _filename), filename);
|
|
}));
|
|
|
|
writeFileSync(filename, 'foobar2');
|