Skip to content

Commit

Permalink
re-enable symlinks resolution
Browse files Browse the repository at this point in the history
fdir 6.4.2 solved the recursive symlinks issue
closes #54
closes #10
  • Loading branch information
SuperchupuDev committed Oct 16, 2024
1 parent 6b89ec2 commit 0182b0e
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
},
"homepage": "https://github.com/SuperchupuDev/tinyglobby#readme",
"dependencies": {
"fdir": "^6.4.0",
"fdir": "^6.4.2",
"picomatch": "^4.0.2"
},
"devDependencies": {
Expand Down
12 changes: 6 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ function crawl(options: GlobOptions, cwd: string, sync: boolean) {
filters: [(p, isDirectory) => matcher(processPath(p, cwd, properties.root, isDirectory, options.absolute))],
exclude: (_, p) => exclude(processPath(p, cwd, properties.root, true, true)),
pathSeparator: '/',
relativePaths: true
// resolveSymlinks: true
relativePaths: true,
resolveSymlinks: true
};

if (options.deep) {
Expand Down
45 changes: 36 additions & 9 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ const fixture = await createFixture({
'.deep/a/a/a.txt': 'a',
'.symlink': {
file: ({ symlink }) => symlink('../a/a.txt'),
dir: ({ symlink }) => symlink('../a')
dir: ({ symlink }) => symlink('../a'),
'.recursive': ({ symlink }) => symlink('..')
}
});

Expand Down Expand Up @@ -198,25 +199,51 @@ test('absolute + empty commonPath', async () => {
assert.deepEqual(files.sort(), [`${cwd.replaceAll('\\', '/')}a/a.txt`, `${cwd.replaceAll('\\', '/')}a/b.txt`]);
});

test('do NOT handle symlinks for now', async () => {
const files = await glob({ patterns: ['.symlink/**'], dot: true, cwd });
assert.deepEqual(files.sort(), ['.symlink/dir', '.symlink/file']);
test('handle symlinks', async () => {
const files = await glob({ patterns: ['.symlink/**'], cwd });
assert.deepEqual(files.sort(), ['.symlink/dir/a.txt', '.symlink/dir/b.txt', '.symlink/file']);
});

test.skip('handle symlinks', async () => {
const files = await glob({ patterns: ['.symlink/**'], dot: true, cwd });
assert.deepEqual(files.sort(), ['.symlink/dir/a.txt', '.symlink/dir/b.txt', '.symlink/file']);
test('handle recursive symlinks', async () => {
const files = await glob({
patterns: ['.symlink/.recursive/**', '!.symlink/.recursive/**/.{a,deep}'],
dot: true,
cwd
});
assert.deepEqual(files.sort(), [
'.symlink/.recursive/.symlink/file',
'.symlink/.recursive/a/a.txt',
'.symlink/.recursive/a/b.txt',
'.symlink/.recursive/b/a.txt',
'.symlink/.recursive/b/b.txt'
]);
});

test.skip('handle symlinks (absolute)', async () => {
const files = await glob({ patterns: ['.symlink/**'], dot: true, absolute: true, cwd });
test('handle symlinks (absolute)', async () => {
const files = await glob({ patterns: ['.symlink/**'], absolute: true, cwd });
assert.deepEqual(files.sort(), [
`${cwd.replaceAll('\\', '/')}.symlink/dir/a.txt`,
`${cwd.replaceAll('\\', '/')}.symlink/dir/b.txt`,
`${cwd.replaceAll('\\', '/')}.symlink/file`
]);
});

test('handle recursive symlinks (absolute)', async () => {
const files = await glob({
patterns: ['.symlink/.recursive/**', '!.symlink/.recursive/**/.{a,deep}'],
absolute: true,
dot: true,
cwd
});
assert.deepEqual(files.sort(), [
`${cwd.replaceAll('\\', '/')}.symlink/.recursive/.symlink/file`,
`${cwd.replaceAll('\\', '/')}.symlink/.recursive/a/a.txt`,
`${cwd.replaceAll('\\', '/')}.symlink/.recursive/a/b.txt`,
`${cwd.replaceAll('\\', '/')}.symlink/.recursive/b/a.txt`,
`${cwd.replaceAll('\\', '/')}.symlink/.recursive/b/b.txt`
]);
});

test('exclude symlinks if the option is disabled', async () => {
const files = await glob({
patterns: ['.symlink/**'],
Expand Down

0 comments on commit 0182b0e

Please sign in to comment.