Skip to content

.gitignore: true makes globby crash on directory with bad read permissions #254

@ChristophP

Description

@ChristophP

In our project we have a folder under the root folder which is .gitignored and used by a docker image to write to database data.
Since it's running inside a Docker container the directory has a different owner and the files can not be read by the user outside of the docker container.

When running globby with the gitignore: true option it crashes.

Steps to reproduce

mkdir someproject
cd someproject
npm init -y && npm i globby
mkdir testdir
chmod -r testdir # remove read access
node --input-type=module -e "const { globby } = await import('globby'); console.log(await globby('test', { gitignore: true }))"

The last line crashes with an error like this:

[Error: EACCES: permission denied, scandir '/Users/d441365/projects/deedop/freigeist/someproject/testdir'] {
  errno: -13,
  code: 'EACCES',
  syscall: 'scandir',
  path: '/Users/d441365/projects/deedop/freigeist/someproject/testdir'
}

Setting gitignore: false makes the error go away

It's not globby's fault that it can't read the directory. Would you consider adding a way to alter globby's behavior in this case though? For example with an option like unreadable: 'skip' which would simply skip directories that can't be read.

PS the whole thing came up when using knip which is using globby under the hood webpro-nl/knip#172

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions