Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: paulmillr/chokidar
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3.5.0
Choose a base ref
...
head repository: paulmillr/chokidar
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3.5.1
Choose a head ref
  • 6 commits
  • 3 files changed
  • 2 contributors

Commits on Jan 12, 2021

  1. Copy the full SHA
    e487878 View commit details
  2. Merge pull request #1062 from CuddlySheep/bugfix/#1058

    fix: Fixed bug in unit test which always fails (closes #1058)
    paulmillr authored Jan 12, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    95dd156 View commit details
  3. Copy the full SHA
    6400338 View commit details
  4. Copy the full SHA
    8f08914 View commit details
  5. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    1322035 View commit details

Commits on Jan 15, 2021

  1. Release 3.5.1.

    paulmillr committed Jan 15, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    paulmillr Paul Miller
    Copy the full SHA
    1d226cb View commit details
Showing with 50 additions and 6 deletions.
  1. +3 −2 lib/nodefs-handler.js
  2. +1 −1 package.json
  3. +46 −3 test.js
5 changes: 3 additions & 2 deletions lib/nodefs-handler.js
Original file line number Diff line number Diff line change
@@ -603,13 +603,14 @@ async _addToNodeFs(path, initialAdd, priorWh, depth, target) {
const follow = this.fsw.options.followSymlinks && !path.includes(STAR) && !path.includes(BRACE_START);
let closer;
if (stats.isDirectory()) {
const absPath = sysPath.resolve(path);
const targetPath = follow ? await fsrealpath(path) : path;
if (this.fsw.closed) return;
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
if (this.fsw.closed) return;
// preserve this symlink's target path
if (path !== targetPath && targetPath !== undefined) {
this.fsw._symlinkPaths.set(targetPath, true);
if (absPath !== targetPath && targetPath !== undefined) {
this.fsw._symlinkPaths.set(absPath, targetPath);
}
} else if (stats.isSymbolicLink()) {
const targetPath = follow ? await fsrealpath(path) : path;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "chokidar",
"description": "Minimal and efficient cross-platform file watching library",
"version": "3.5.0",
"version": "3.5.1",
"homepage": "https://github.com/paulmillr/chokidar",
"author": "Paul Miller (https://paulmillr.com)",
"contributors": [
49 changes: 46 additions & 3 deletions test.js
Original file line number Diff line number Diff line change
@@ -1134,9 +1134,11 @@ const runTests = (baseopts) => {
});
it('should not recurse indefinitely on circular symlinks', async () => {
await fs_symlink(currentDir, getFixturePath('subdir/circular'));
const watcher = chokidar_watch();
await waitForWatcher(watcher);
// return true;
return new Promise((resolve, reject) => {
const watcher = chokidar_watch();
watcher.on(EV_ERROR, resolve());
watcher.on(EV_READY, reject('The watcher becomes ready, although he watches a circular symlink.'));
})
});
it('should recognize changes following symlinked dirs', async () => {
const linkedFilePath = sysPath.join(linkedDir, 'change.txt');
@@ -2141,6 +2143,47 @@ const runTests = (baseopts) => {
watcher.close();
}
});

it('should detect changes to symlink folders, even if they were deleted before', async () => {
const id = subdirId.toString();
const relativeWatcherDir = sysPath.join(FIXTURES_PATH_REL, id, 'test');
const linkedRelativeWatcherDir = sysPath.join(FIXTURES_PATH_REL, id, 'test-link');
await fs_symlink(sysPath.resolve(relativeWatcherDir), linkedRelativeWatcherDir);
const watcher = chokidar.watch(linkedRelativeWatcherDir, {
persistent: true,
});
try {
const events = [];
watcher.on('all', (event, path) =>
events.push(`[ALL] ${event}: ${path}`)
);
const testSubDir = sysPath.join(relativeWatcherDir, 'dir');
const testSubDirFile = sysPath.join(relativeWatcherDir, 'dir', 'file');

// Command sequence from https://github.com/paulmillr/chokidar/issues/1042.
await delay();
await fs_mkdir(relativeWatcherDir);
await fs_mkdir(testSubDir);
// The following delay is essential otherwise the call of mkdir and rmdir will be equalize
await delay(300);
await fs_rmdir(testSubDir);
// The following delay is essential otherwise the call of rmdir and mkdir will be equalize
await delay(300);
await fs_mkdir(testSubDir);
await write(testSubDirFile, '');
await delay(300);

chai.assert.deepStrictEqual(events, [
`[ALL] addDir: ${sysPath.join('test-fixtures', id, 'test-link')}`,
`[ALL] addDir: ${sysPath.join('test-fixtures', id, 'test-link', 'dir')}`,
`[ALL] unlinkDir: ${sysPath.join('test-fixtures', id, 'test-link', 'dir')}`,
`[ALL] addDir: ${sysPath.join('test-fixtures', id, 'test-link', 'dir')}`,
`[ALL] add: ${sysPath.join('test-fixtures', id, 'test-link', 'dir', 'file')}`,
]);
} finally {
watcher.close();
}
});
});
};