Comments (22)
Works properly on Unix.
from node-glob.
Seems like it works properly on Windows as well:
C:\globtest\node-glob\test>cat g.js
var glob = require('glob');
var path = require('path');
glob(__dirname + '/**/*', function (err, matches) {
console.log(matches); // matches is ok
});
C:\globtest\node-glob\test>node g.js
[ 'C:\\globtest\\node-glob\\test/00-setup.js',
'C:\\globtest\\node-glob\\test/bash-comparison.js',
'C:\\globtest\\node-glob\\test/bash-results.json',
'C:\\globtest\\node-glob\\test/cwd-test.js',
'C:\\globtest\\node-glob\\test/g.js',
'C:\\globtest\\node-glob\\test/mark.js',
'C:\\globtest\\node-glob\\test/pause-resume.js',
'C:\\globtest\\node-glob\\test/root-nomount.js',
'C:\\globtest\\node-glob\\test/root.js',
'C:\\globtest\\node-glob\\test/zz-cleanup.js' ]
from node-glob.
This is using glob 3.1.17, btw.
from node-glob.
@isaacs thats really strange because the same gives me an empty array.
I've tested this in two windows 7 machines with the same result. I noticed that you did cat
in the command line, which is not available. Are you running that in cygwin or similar? I'm running the same tests in a normal cmd.exe.
I'm using [email protected]. If I install [email protected] everything works fine.
from node-glob.
Version [email protected] is also fine, but [email protected] has the issue. Something after it is the culprit.
from node-glob.
I installed the msysutil suite with git, but it's normal cmd otherwise. I just don't know most of the windows equivalents.
What is the actual output?
from node-glob.
That is, what is the output if glob(__dirname + '/**/*')
vs the output of glob('**/*')
?
from node-glob.
Also, what is node -v
?
from node-glob.
v.0.8.16, going to add some screenshots.
from node-glob.
Type Alt-Space, E, K, then select with your mouse, then press Enter. This copies the output to your clipboard, and you can paste it into a code block with ```
from node-glob.
The test
folder has one file called dsadsa.txt
.
Running:
var glob = require('glob');
glob('test/**/*', function (err, matches) {
console.log(matches);
});
Running:
var glob = require('glob');
glob(__dirname + '/test/**/*', function (err, matches) {
console.log(matches);
});
from node-glob.
Put a /
in front of 'test'
. Echo out the actual path that you're globbing, you'll see the problem right away, I'm sure. (__dirname
doesn't end in a slash.)
from node-glob.
-glob(__dirname + 'test/**/*', function (err, matches) {
+glob(__dirname + '/test/**/*', function (err, matches) {
from node-glob.
@isaacs it was a typo typing the comment, the actual file contains the /
from node-glob.
var glob = require('glob');
var pattern = __dirname + '/test/**/*';
console.log('pattern is:', pattern);
glob(pattern, function (err, matches) {
console.log(matches);
});
from node-glob.
Also tried path.normalize
before passing the pattern, same issue.
Maybe the issue is related to the fact that the pattern contains backslahes?
from node-glob.
Seems not.
var glob = require('glob');
var pattern = (__dirname + '/test/**/*').replace(/\\/g, '/');
console.log('pattern is:', pattern);
glob(pattern, function (err, matches) {
console.log(matches);
});
..didn't fixed the issue.
any thoughts?
from node-glob.
Aha! Ok, reproducing now:
var glob = require('glob');
var p1 = 'test/**/*';
glob(p1, function (err, matches) {
console.log(p1, matches);
});
var p2 = __dirname + '/' + p1;
glob(p2, function (er, matches) {
console.log(p2, matches);
});
Output:
c:\globtest\Helena>node test.js
c:\globtest\Helena/test/**/* []
test/**/* [ 'test/asdasd.txt',
'test/dir',
'test/dir/a.txt',
'test/dir/b.txt',
'test/dsadsa.txt' ]
Folder structure:
test/
test/asdasd.txt
test/dir/
test/dir/a.txt
test/dir/b.txt
test/dsadsa.txt
from node-glob.
Now I'm confused about why it's working sometimes, but not in this specific case... Very strange.
from node-glob.
I'm glad that you reproduced it. Looking forward for a new release that fixes this. Going to truncate glob on 3.1.15 for now.
from node-glob.
@isaacs It now expands correctly but using mark: true
does not mark directories with / or \ at the end.
from node-glob.
@satazor Separate issue. Please file a separate bug with a reproduction case.
from node-glob.
Related Issues (20)
- 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
- Neutral JavaScript runtime support (Deno, Bun, etc)
- UNC not working in glob.sync HOT 4
- Glob behaves differently when handed a drive letter root as its directory (Windows) HOT 2
- Inconsistency when run in root drive path `/`, prefixes match with `/` HOT 3
- Update to path-scurry and glob broke npm temporarily HOT 3
- Missing Release of Resource after Effective Lifetime [Medium Severity] HOT 1
- Querry regading error HOT 1
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.