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

When using glob can't exclude all directs #56260

Open
babakfp opened this issue Dec 15, 2024 · 0 comments
Open

When using glob can't exclude all directs #56260

babakfp opened this issue Dec 15, 2024 · 0 comments
Labels
fs Issues and PRs related to the fs subsystem / file system.

Comments

@babakfp
Copy link

babakfp commented Dec 15, 2024

Version

v23.4.0

Platform

Microsoft Windows NT 10.0.22631.0 x64

Subsystem

No response

What steps will reproduce the bug?

  1. Create a folder and open it in your code editor (we use this as current working directory).

  2. Make/create the files/folders shown below:

    src
    src\a
    src\a\b
    src\a\c
    src\index.ts
    src\zip.ts
    
  3. Run the code below:

    console.log(
        fs.globSync("src/**", {
            withFileTypes: true,
            cwd: process.cwd(),
            exclude: (dirent) => {
                console.log(dirent)
            },
        }),
    )

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

.

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

I expect the exclude function to receive all the output directs, so that they can be excluded. (See "Additional information" part).

Even with just returning true in exclude function, you can exclude DirentFromStats from the result.

What do you see instead?

The first direct from output is missing in exclude. (See "Additional information" part).

Additional information

Exclude:

Dirent {
  name: 'a',
  parentPath: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src',
  path: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src',
  [Symbol(type)]: 2
}
Dirent {
  name: 'index.ts',
  parentPath: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src',
  path: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src',
  [Symbol(type)]: 1
}
Dirent {
  name: 'zip.ts',
  parentPath: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src',
  path: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src',
  [Symbol(type)]: 1
}
Dirent {
  name: 'b',
  parentPath: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src\\a',
  path: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src\\a',
  [Symbol(type)]: 2
}
Dirent {
  name: 'c',
  parentPath: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src\\a',
  path: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src\\a',
  [Symbol(type)]: 2
}

Output:

[
  DirentFromStats {
    name: 'src',
    parentPath: 'C:\\Users\\Babak\\Documents\\Code\\tosk',
    path: 'C:\\Users\\Babak\\Documents\\Code\\tosk',
    [Symbol(type)]: null,
    [Symbol(stats)]: Stats {
      dev: 1247631908,
      mode: 16822,
      nlink: 1,
      uid: 0,
      gid: 0,
      rdev: 0,
      blksize: 4096,
      ino: 1970324837878618,
      size: 0,
      blocks: 0,
      atimeMs: 1734234059936.9617,
      mtimeMs: 1734231659493.8164,
      ctimeMs: 1734231659493.8164,
      birthtimeMs: 1734197097735.2148
    }
  },
  Dirent {
    name: 'index.ts',
    parentPath: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src',
    path: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src',
    [Symbol(type)]: 1
  },
  Dirent {
    name: 'zip.ts',
    parentPath: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src',
    path: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src',
    [Symbol(type)]: 1
  },
  Dirent {
    name: 'a',
    parentPath: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src',
    path: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src',
    [Symbol(type)]: 2
  },
  Dirent {
    name: 'c',
    parentPath: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src\\a',
    path: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src\\a',
    [Symbol(type)]: 2
  },
  Dirent {
    name: 'b',
    parentPath: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src\\a',
    path: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src\\a',
    [Symbol(type)]: 2
  }
]
@mertcanaltin mertcanaltin added the fs Issues and PRs related to the fs subsystem / file system. label Dec 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fs Issues and PRs related to the fs subsystem / file system.
Projects
None yet
Development

No branches or pull requests

2 participants