Skip to content

fs.glob excludes patterns and input pattern uses different casing (case-sensitive) windows #58991

@mizulu

Description

@mizulu

Version

24.3.0

Platform

x64 windows

Subsystem

No response

What steps will reproduce the bug?

on windows

files structure

root
   |_ a
       | node_modules
let r = await glob("a/node_moduleS", {
    cwd: "root",
})

let files = await Array.fromAsync(r)
console.log(files);

output

 ['a'\\node_moduleS`]

This is the first issue, the result preserves the original glob casing instead of the casing on the filesystem

expected

-['a'\\node_moduleS`]
+['a'\\node_modules`]

when we try to exclude with the actual casing on the filesystem
the exclude actually uses case aware, and in this case it fails to exclude the actual path
on the file system

let r = await glob("a/node_moduleS", {
    cwd: "root",
    exclude: ["a/node_modules"]
})

let files = await Array.fromAsync(r)
console.log(files);

output

[ 'a\\node_moduleS' ]

instead of the expected

-  [ 'a\\node_moduleS' ]
+ []

How often does it reproduce? Is there a required condition?

always

What is the expected behavior? Why is that the expected behavior?

  1. globing should always return the actual casing from the filesystem
  2. if the glob pattern is case insensitive so should the exclude patterns.
  3. we should be able to configure the casing of the matcher because on windows we may have case sensitive file system too. see final note for the proposal of enhancement

What do you see instead?

  1. on windows the glob results are returned with the casing of the pattern instead of preserving the filesystem casing
  2. the exclude patterns are case sensitive

Additional information

Additionally I think the glob case sensitive should be configurable
either be explicitly

 await glob("a/node_moduleS", {
    cwd: "root",
    casing: "default",     // default - window case-insensitive , linux - case sensitive
                           // yes     - case sensitive regardless of operation system 
                           // no      - case insensitive regardless of operation system
})

windows also supports case sensitive file system as you can see here
https://learn.microsoft.com/en-us/windows/wsl/case-sensitivity

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    fsIssues and PRs related to the fs subsystem / file system.windowsIssues and PRs related to the Windows platform.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions