Git Product home page Git Product logo

Comments (14)

MartinKolarik avatar MartinKolarik commented on May 26, 2024 1

Is it only when the path is absolute?

No, it's the same for relative paths as well. But it's only an issue when a dotfile is at the same level as ** - if it's inside a directory, it works correctly:

mm.isMatch('/aaa/bbb/ccc/.git', '/aaa/bbb/**'); // => false; correct

from micromatch.

tunnckoCore avatar tunnckoCore commented on May 26, 2024

Actually, looking the tests.. they also looks wrong? not sure

 mm.makeRe('.gitignore', {dot: true}).test('.gitignore').should.be.true;
 mm.makeRe('.gitignore', {dot: false}).test('.gitignore').should.be.true;
 mm.makeRe('.gitignore').test('.gitignore').should.be.true;

from micromatch.

MartinKolarik avatar MartinKolarik commented on May 26, 2024

Those tests are correct. It should match dotfiles even with dot: false when dot is explicitly part of the pattern. dot: true/false only affects wildcards.

from micromatch.

tunnckoCore avatar tunnckoCore commented on May 26, 2024

It should match dotfiles even

I don't think so. That's the idea of that option for me.

Nevermind, issue is for other bug.

from micromatch.

tunnckoCore avatar tunnckoCore commented on May 26, 2024

@jonschlinkert the whole point of this issue is because if we have directory with 1 file and 1 directory, and we want to pass foobar/** pattern it will return only the 1 file and 1 directory without the foobar/ and this make sense because it comes as foobar and pattern want at least foobar/, so the trailing slash is problem. So i'm forced to add trailing slash before pass to micromatch.

Doesn't it make sense foobar/** to match foobar and foobar/? Exactly because * is zero or more?

from micromatch.

jonschlinkert avatar jonschlinkert commented on May 26, 2024

It should match dotfiles even with dot: false when dot is explicitly part of the pattern.

correct. the bash specification says that when /. is part of your pattern (or ^.), it will always match dotfiles, even if options.dot is false.

from micromatch.

tunnckoCore avatar tunnckoCore commented on May 26, 2024

correct.

Okey, got it. But issue is a bit another, see my last post. And see this example it may clear it a bit

function matchPlugin (patterns, options) {
  var matcher = require('is-match')
  var isMatch = matcher(patterns, options)

  return function matchPlugin (app) {
    return function (file) {
      var fp = file.path

      // this little hack is needed, for example:
      // pattern: foo/bar/**
      // -> foo/bar/baz
      // -> foo/bar/baz/qux.js
      // -> foo/bar/
      // -> foo/bar -> fails, so we tweak it with this hack
      if (file.stat.isDirectory()) {
        fp = file.path.charAt(-1) === '/' ? file.path.slice(0, -1) : file.path
        fp = fp + '/'
      }
      if (!file.exclude && !isMatch(fp)) file.exclude = true
    }
  }
}

Btw, is the refactor is near to push to github? :)

from micromatch.

jonschlinkert avatar jonschlinkert commented on May 26, 2024

Did you notice you're using .makeRe on the filepath, not on the pattern?

is the refactor is near to push to github? :)

maybe, I'll look.

from micromatch.

MartinKolarik avatar MartinKolarik commented on May 26, 2024

@jonschlinkert from @tunnckoCore's first post, it seems there actually is a bug:

mm.isMatch('/aaa/bbb/.git', '/aaa/bbb/**'); // => true; should be false

from micromatch.

jonschlinkert avatar jonschlinkert commented on May 26, 2024

yeah that's what I was thinking as well. but I hadn't had a chance to check. Is it only when the path is absolute?

from micromatch.

tunnckoCore avatar tunnckoCore commented on May 26, 2024

@MartinKolarik yea, but that's another bug, maybe we should separate them in separate issues.

I'm talking for another.

var micromatch = require('micromatch')
var isMatch = micromatch.matcher('foo/bar/**')
console.log(isMatch('foo/bar')) // => false, i think it make sense to pass?
console.log(isMatch('foo/bar/')) // => true
console.log(isMatch('foo/bar/baz')) // => true
console.log(isMatch('foo/bar/baz/fez')) // => true
console.log(isMatch('foo/bar/baz/qux.js')) // => true

Is it only when the path is absolute?

Hmm, I thought answer was yes, but huh.

var micromatch = require('micromatch')
console.log(micromatch.isMatch('/aaa/bbb/.git', '/aaa/bbb/**', {dot: true}))
console.log(micromatch.isMatch('/aaa/bbb/.git', '/aaa/bbb/**', {dot: false}))
console.log(micromatch.isMatch('aaa/bbb/.git', 'aaa/bbb/**', {dot: true}))
console.log(micromatch.isMatch('aaa/bbb/.git', 'aaa/bbb/**', {dot: false}))

obviously, no.

from micromatch.

jonschlinkert avatar jonschlinkert commented on May 26, 2024

maybe we should separate them in separate issues.

let's do that please. Also try to just use the minimum reduced use case to illustrate the bug. thanks

from micromatch.

MartinKolarik avatar MartinKolarik commented on May 26, 2024

@MartinKolarik yea, but that's another bug, maybe we should separate them in separate issues.

I see. From your original post, I thought this was the problem you were reporting 😄

console.log(isMatch('foo/bar')) // => false, i think it make sense to pass?

I that case, bar might be a file in foo directory, and definitely shouldn't match.

from micromatch.

jonschlinkert avatar jonschlinkert commented on May 26, 2024

closing this issue since we're splitting out

from micromatch.

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.