Code Monkey home page Code Monkey logo

Comments (14)

isaacs avatar isaacs commented on August 19, 2024

Yeah, that's a bug.

from node-glob.

isaacs avatar isaacs commented on August 19, 2024

Can you please try with the latest push to master? Also published as [email protected].

from node-glob.

cadorn avatar cadorn commented on August 19, 2024

Cannot tell because glob is not working for me at all now. Seems to be a regression. Locked to 3.0.x for now. No time to look further ATM.

from node-glob.

isaacs avatar isaacs commented on August 19, 2024

Could you explain a little bit what "not working for me at all now" means?

Is it throwing an error? Hanging? Doesn't install?

from node-glob.

cadorn avatar cadorn commented on August 19, 2024

No error. Exact same input, now no output.

Code: https://github.com/sourcemint/bundler-js/blob/fa9e5a02e25e189b1d6efe6f53d6f399552798b7/lib/bundler.js#L176-196

Broad test case: https://github.com/sourcemint/platform-nodejs (npm test)

Things should fail.

I'll try and narrow things down when I have time if you don't beat me to it.

from node-glob.

isaacs avatar isaacs commented on August 19, 2024

Aha. It's getting confused when the cwd isn't process.cwd.

from node-glob.

cadorn avatar cadorn commented on August 19, 2024

Ah, that would explain it. What is the exat difference between the cwd and root options?

from node-glob.

isaacs avatar isaacs commented on August 19, 2024

v3.1.3 should have what you need. Thanks!

from node-glob.

isaacs avatar isaacs commented on August 19, 2024

root is used when you want patterns starting with / to be interpreted as being in some specific directory.

Seems like that's broken atm too, though.

from node-glob.

cadorn avatar cadorn commented on August 19, 2024

I thought that is what cwd is for. Can you explain the difference?

from node-glob.

isaacs avatar isaacs commented on August 19, 2024

Say you have this structure:

a
+-- b
|    `-- c
+-- c

Then glob('/c', {root: 'a', cwd: 'a/b'}) would match a/c but not a/b/c. If you drop the slash, then you see that glob('c', {root:'a',cwd:'a/b'}) would match the a/b/c file, but not the a/c file.

What's not immediately clear is how best to express this in the results. I'm thinking that any and all patterns that start with / should show up in the results as a full absolute path, with the root config pre-pended.

Another option would be to resolve everything against the cwd, but that breaks the symmetry with how it works by default, when cwd is process.cwd(), and root is /. The "evil owl" pattern {*,/*} returns /etc, /usr, /home, etc... for the "absolute" part, but foo, bar, baz, ... for the "relative" part.

Setting a root is important for handling situations like ignore files. /foo.txt in a .gitignore will prevent ./foo.txt from being included, but not ./bar/foo.txt.

When building a tarball or something, though, you probably don't want to get the full path, since that'll result in adding a bunch of noise into your tarball, so this will have to be configurable, with the default perhaps being to prepend the root, and an option to disable, akin to rsync's '--no-implied-dirs' option.

from node-glob.

cadorn avatar cadorn commented on August 19, 2024

Why not default root to cwd which defaults to process.cwd() and always return relative path from root in result.

Prefixing root to result paths requires me to strip it again in most cases (I need relative paths from a given root). Also, if you pass in root it is trivial for you to map the result array after and prefix root if you need to.

So result paths always start with / so you can do PATH.existsSync(root + result[x]) where root may be /etc and result[x] = /hosts.

from node-glob.

isaacs avatar isaacs commented on August 19, 2024

Because the default root is /, not the cwd. The evil owl {/*,*} needs to return everything in / as well as everything in .. So, by default, yes it is prefixed.

If you want to disable this, set { nomount: true } in the options object.

from node-glob.

cadorn avatar cadorn commented on August 19, 2024

v3.1.4 works now. Thanks.

from node-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.