Comments (14)
Yeah, that's a bug.
from node-glob.
Can you please try with the latest push to master? Also published as [email protected].
from node-glob.
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.
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.
No error. Exact same input, now no output.
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.
Aha. It's getting confused when the cwd isn't process.cwd.
from node-glob.
Ah, that would explain it. What is the exat difference between the cwd
and root
options?
from node-glob.
v3.1.3 should have what you need. Thanks!
from node-glob.
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.
I thought that is what cwd
is for. Can you explain the difference?
from node-glob.
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.
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.
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.
v3.1.4 works now. Thanks.
from node-glob.
Related Issues (20)
- Compile error with 10.3.8 HOT 3
- Typescript: Cannot find type declarations HOT 2
- Cannot find module 'glob' or its corresponding type declarations HOT 1
- add a flag like `--ignore-path` similar to Prettier HOT 1
- New version jackspeak break commonjs libs HOT 6
- Are there return value examples for versions 7.1.6 and 10 glob.sync HOT 4
- Recent bump of `jackspeak` dep should have been a major version bump HOT 8
- Patch update 10.3.6 -> 10.3.7 appears to have multiple breaking changes HOT 3
- Redundant `//?/` HOT 4
- Clarify nocase documentation (specifically when setting it to not match OS behavior) HOT 2
- ignore option is not working with relative path HOT 1
- Using path.join no results HOT 1
- CWE-772 on dependency inflight HOT 1
- Memory leak in inflight dependency HOT 4
- Using vulnerable package inflight HOT 1
- `glob.sync(...)` is not returning values when `".."` and `nocase: true` are used together. HOT 2
- results are in reverse alphabetical order HOT 5
- npm i glob
- npm i glob
- `follow: true` doesn't follow more that 1 symbolic link HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-glob.