Giter Site home page Giter Site logo

Comments (8)

dylang avatar dylang commented on August 23, 2024

I'm not sure if this is the same issue:

+ fixtures
  + dir1
  + dir2
// I expect this to return [ 'dir1', 'dir2' ]
// and it does
const results = await glob(['fixtures/*'], { onlyDirectories: true });
// I expect this to return [ 'fixtures' ],
// but it returns [ ]
const results = await glob(['fixtures'], { onlyDirectories: true });

from fast-glob.

mrmlnc avatar mrmlnc commented on August 23, 2024

Hello, @dylang,

Looks like separated issue. Please create a issue for your problem.

I can say right now, that this is works on my machine:

tree fixtures/
fixtures/
├── b
│   └── c
│       ├── md.md
│       └── txt.txt
├── md.md
└── txt.txt
const fg = require('fast-glob');

const entries0 = fg.sync(['fixtures/*'], { onlyDirectories: true });

console.dir(entries0, { colors: true });  // [ 'fixtures/b' ]

const entries1 = fg.sync(['fixtures'], { onlyDirectories: true });

console.dir(entries1, { colors: true });  // [ 'fixtures' ]

Are you sure you're using the latest version of the package? But I need more information about your case. Your version of the fast-glob package, OS and etc.

from fast-glob.

dylang avatar dylang commented on August 23, 2024

@mrmlnc You are correct, older version via globby at fault, thanks for the quick reply!

from fast-glob.

mrmlnc avatar mrmlnc commented on August 23, 2024

Blocked by migrate to @nodelib/fs.walk (nodelib/nodelib#9).

from fast-glob.

lcrespom avatar lcrespom commented on August 23, 2024

I am executing this code:

const glob = require('fast-glob').sync
console.log(glob('/*', { onlyFiles: false }))

And I get [] as the output. I am using MacOS and v12.14.0.
I think this problem is related with this issue, but maybe it's a different one.

from fast-glob.

mrmlnc avatar mrmlnc commented on August 23, 2024

@lcrespom,

Nope, if you want to get only directories, then you need to use the onlyDirectories option. When you disable the onlyFiles option the onlyDirectories option is not automatically enabled.

from fast-glob.

lcrespom avatar lcrespom commented on August 23, 2024

I don't want only directories, I want to get all dirs and files of my root directory, but instead I am getting an empty array, and I can assure you my root directory is not empty.

P.S. even if I wanted only directories, I have just tested this code:

const glob = require('fast-glob').sync
console.log(glob('/*', { onlyFiles: false, onlyDirectories: true }))

...and it also displays [].

from fast-glob.

75lb avatar 75lb commented on August 23, 2024

Any update on a fix for this? This issue is preventing me switching to fast-glob from node-glob (without a breaking change)..

$ tree
.
├── 1
│   ├── one
│   └── two
│       └── three

$ echo 1/**
1/ 1/one 1/two 1/two/three

$ node
Welcome to Node.js v16.2.0.
> fg = require('fast-glob')
> fg.sync(['1/**'], { onlyFiles: false })
[ '1/one', '1/two', '1/two/three' ]

As you can see in the example above, bash expands 1/** to four paths while fast-glob only expands to three paths ('1/' is missing).

from fast-glob.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.