Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

glob: Pattern with trailing / unexpectedly matches a file. #628

Closed
dbartol opened this issue Nov 9, 2020 · 1 comment · Fixed by #805
Closed

glob: Pattern with trailing / unexpectedly matches a file. #628

dbartol opened this issue Nov 9, 2020 · 1 comment · Fixed by #805
Labels
bug Something isn't working glob

Comments

@dbartol
Copy link

dbartol commented Nov 9, 2020

Describe the bug
When implicitDescendants is true (the default), a pattern with a trailing slash will match a file path, rather than just a directory path as intended. For example, the pattern foo/ will match a file named foo, rather than just a directory named foo. This behavior is inconsistent with other common glob implementations, include .gitignore and node-glob. It also means that there is no way to specify a pattern that matches only files.

To Reproduce
Run the following TypeScript code:

import * as glob from '@actions/glob';
import * as fs from 'fs';

async function repro(): Promise<void> {
  const globber = await glob.create('foo/', {
    implicitDescendants: true
  });

  await fs.promises.writeFile('foo', 'text');

  const matches = await globber.glob();
  console.log(matches);
}

repro();

Expected behavior
No matches are found by the globber.

Actual behavior
Output (when run from C:\Src\Repro):

::debug::implicitDescendants 'true'
::debug::followSymbolicLinks 'true'
::debug::implicitDescendants 'true'
::debug::omitBrokenSymbolicLinks 'true'
::debug::Search path 'C:\Src\Repro\foo'
[ 'C:\\Src\\Repro\\foo' ]

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: N/A
@luketomlinson
Copy link
Contributor

Resolved by #805

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working glob
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants