Skip to content

fix: read the root of a drive for patterns like C:/* on Windows - #527

Open
SulimanAbdulrazzaq wants to merge 1 commit into
mrmlnc:masterfrom
SulimanAbdulrazzaq:fix/windows-drive-root-base
Open

SulimanAbdulrazzaq wants to merge 1 commit into
mrmlnc:masterfrom
SulimanAbdulrazzaq:fix/windows-drive-root-base

Conversation

@SulimanAbdulrazzaq

Copy link
Copy Markdown

What is the purpose of this pull request?

Fixes #375. On Windows, a pattern for the root of a drive, such as C:/*, lists the current working directory instead of the drive root.

glob-parent returns C: as the base directory of C:/* (gulpjs/glob-parent#63). Windows resolves a drive letter without a separator to the current directory on that drive, so path.resolve(cwd, 'C:') is the cwd. The entries found there are then reported under the drive, for example C:/src for the repository's own src directory. C:/./* already works because its base is C:/..

What changes did you make? (Give an overview)

  • groupPatternsByBaseDirectory now keeps the trailing slash when the base is a bare drive letter taken from a X:/… pattern, so the base of C:/* is C:/, the same way /* gets /. This only applies on Windows. On other platforms C: is an ordinary relative directory name, so nothing changes there.
  • The check is a small helper in utils/path next to appendTrailingSeparatorToDeviceRoot, and it runs after getBaseDirectory rather than inside it.
  • Tests:
    • A unit test for the helper.
    • A grouping test in managers/tasks.spec.ts.
    • A globSync test that uses a custom fs.readdirSync to check that the drive root is the directory being read.

glob-parent returns `C:` as the base directory of `C:/*`. Windows resolves a
drive letter without a separator to the current directory on that drive, so
the pattern listed the current working directory and reported its entries as
if they were in the drive root.

Keep the trailing separator for such bases, the same way `/*` gets `/`.

Fixes mrmlnc#375
@mergify

mergify Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@SulimanAbdulrazzaq

Copy link
Copy Markdown
Author

@mrmlnc when you have a moment, could you approve the workflow runs on this one? It fixes #375: on Windows, a pattern for the root of a drive such as C:/* lists the current working directory instead of the drive root. CI, Benchmark and CodeQL are waiting for approval, and the branch has no conflicts.

@SulimanAbdulrazzaq

Copy link
Copy Markdown
Author

@mrmlnc when you have a moment, could one of you approve the workflow runs and take a look at this one? No checks have run on the current head yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Strange behavior at Windows root dir like D:/

1 participant