Git Product home page Git Product logo

Comments (1)

Jason3S avatar Jason3S commented on July 3, 2024

A bit of info:

  • It looks like the behavior changed when picomatch was updated.
  • It seems to be related to the default behavior of the windows option.
  • Behavior of isMatch does not match makeRe().test.
import assert from 'node:assert';
import path from 'node:path';
import { fileURLToPath } from 'node:url';

import mm from 'micromatch';

const __filename = fileURLToPath(import.meta.url);

const glob = '**/' + __filename.split(path.sep).slice(-2).join('/');
const filePosix = __filename.replaceAll(path.sep, '/');
const fileWin = __filename.replaceAll(path.sep, '\\');

const posixTest = {
    isMatch: mm.isMatch(filePosix, glob),
    regExpTest: mm.makeRe(glob).test(filePosix),
};

const winTest = {
    isMatch: mm.isMatch(fileWin, glob),
    regExpTest: mm.makeRe(glob).test(fileWin),
};

console.log('%o', {
    glob,
    filePosix,
    fileWin,
    posixTest,
    winTest,
});

assert(posixTest.isMatch === posixTest.regExpTest);
assert(winTest.isMatch === winTest.regExpTest);

Result:

{
  glob: '**/test/mtest.mjs',
  filePosix: 'C:/Users/jdent/test/mtest.mjs',
  fileWin: 'C:\\Users\\jdent\\test\\mtest.mjs',
  posixTest: { isMatch: true, regExpTest: true },
  winTest: { isMatch: false, regExpTest: true }
}

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.