Code Monkey home page Code Monkey logo

Comments (22)

isaacs avatar isaacs commented on August 19, 2024

Works properly on Unix.

from node-glob.

isaacs avatar isaacs commented on August 19, 2024

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.

isaacs avatar isaacs commented on August 19, 2024

This is using glob 3.1.17, btw.

from node-glob.

satazor avatar satazor commented on August 19, 2024

@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.

satazor avatar satazor commented on August 19, 2024

Version [email protected] is also fine, but [email protected] has the issue. Something after it is the culprit.

from node-glob.

isaacs avatar isaacs commented on August 19, 2024

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.

isaacs avatar isaacs commented on August 19, 2024

That is, what is the output if glob(__dirname + '/**/*') vs the output of glob('**/*')?

from node-glob.

isaacs avatar isaacs commented on August 19, 2024

Also, what is node -v?

from node-glob.

satazor avatar satazor commented on August 19, 2024

v.0.8.16, going to add some screenshots.

from node-glob.

isaacs avatar isaacs commented on August 19, 2024

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.

satazor avatar satazor commented on August 19, 2024

The test folder has one file called dsadsa.txt.

Running:

var glob = require('glob');

glob('test/**/*', function (err, matches) {
    console.log(matches);
});

ss1_1

Running:

var glob = require('glob');

glob(__dirname + '/test/**/*', function (err, matches) {
    console.log(matches);
});

ss2

from node-glob.

isaacs avatar isaacs commented on August 19, 2024

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.

isaacs avatar isaacs commented on August 19, 2024
-glob(__dirname + 'test/**/*', function (err, matches) {
+glob(__dirname + '/test/**/*', function (err, matches) {

from node-glob.

satazor avatar satazor commented on August 19, 2024

@isaacs it was a typo typing the comment, the actual file contains the /

from node-glob.

satazor avatar satazor commented on August 19, 2024
var glob = require('glob');

var pattern = __dirname + '/test/**/*';
console.log('pattern is:', pattern);

glob(pattern, function (err, matches) {
    console.log(matches);
});

ss3

from node-glob.

satazor avatar satazor commented on August 19, 2024

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.

satazor avatar satazor commented on August 19, 2024

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.

isaacs avatar isaacs commented on August 19, 2024

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.

isaacs avatar isaacs commented on August 19, 2024

Now I'm confused about why it's working sometimes, but not in this specific case... Very strange.

from node-glob.

satazor avatar satazor commented on August 19, 2024

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.

satazor avatar satazor commented on August 19, 2024

@isaacs It now expands correctly but using mark: true does not mark directories with / or \ at the end.

from node-glob.

isaacs avatar isaacs commented on August 19, 2024

@satazor Separate issue. Please file a separate bug with a reproduction case.

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.