-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
Description
What is the problem this feature will solve?
The node:fs.glob function does not traverse symbolic links that point to directories. It does not expose an option to enable traversal of directory symlinks, unlike the behavior found in other third-party globbing libraries.
This means that if a project structure includes a directory symlink (e.g., a package symlinked into node_modules, or a shared resource directory symlinked into a project), fs.glob will not discover files within that symlinked directory.
fs.glob should provide an option (e.g., follow: true or followSymlinks: true) that allows it to traverse symbolic links that point to directories, similar to how many other globbing utilities operate. When this option is enabled, fs.glob should discover files within symlinked directories.
Steps to reproduce
mkdir -p test-glob-symlink/real-dir
cd test-glob-symlink
echo "hello NodeJS Team" > real-dir/file.txt
ln -s real-dir symlinked-dir
Run using node:
const fs = require('node:fs/promises');
const path = require('node:path');
async function testGlob() {
const rootPath = path.resolve('./test-glob-symlink');
const patterns = ['**'];
console.log(`Scanning root: ${rootPath}`);
const files = [];
for await (const entry of fs.glob(patterns, { cwd: rootPath, withFileTypes: true })) {
if (entry.isFile()) {
files.push(path.join(rootPath, entry.name));
}
}
console.log('Found files:', files);
}
testGlob();
What is the feature you are proposing to solve the problem?
fs.glob should provide an option (for example followSymlinks: true) that allows it to traverse symbolic links that point to directories, similar to how many other globbing utilities operate.
What alternatives have you considered?
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status