Skip to content

Commit

Permalink
3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jonschlinkert committed Oct 29, 2023
1 parent 49d10c4 commit bc719c4
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ const isWindows = os.platform() === 'win32';

function picomatch(glob, options, returnState = false) {
// default to os.platform()
if (options.windows === null || options.windows === undefined) {
options.windows = isWindows;
if (options && (options.windows === null || options.windows === undefined)) {
// don't mutate the original options object
options = { ...options, windows: isWindows };
}
return pico(glob, options, returnState);
}
Expand Down
19 changes: 12 additions & 7 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ exports.removeBackslashes = str => {
};

exports.supportsLookbehinds = () => {
const segs = process.version.slice(1).split('.').map(Number);
if (segs.length === 3 && segs[0] >= 9 || (segs[0] === 8 && segs[1] >= 10)) {
return true;
if (typeof process !== 'undefined') {
const segs = process.version.slice(1).split('.').map(Number);
if (segs.length === 3 && segs[0] >= 9 || (segs[0] === 8 && segs[1] >= 10)) {
return true;
}
}
return false;
};
Expand Down Expand Up @@ -55,9 +57,12 @@ exports.wrapOutput = (input, state = {}, options = {}) => {
};

exports.basename = (path, { windows } = {}) => {
if (windows) {
return path.replace(/[\\/]$/, '').replace(/.*[\\/]/, '');
} else {
return path.replace(/\/$/, '').replace(/.*\//, '');
const segs = path.split(windows ? /[\\/]/ : '/');
const last = segs[segs.length - 1];

if (last === '') {
return segs[segs.length - 2];
}

return last;
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "picomatch",
"description": "Blazing fast and accurate glob matcher written in JavaScript, with no dependencies and full support for standard and extended Bash glob features, including braces, extglobs, POSIX brackets, and regular expressions.",
"version": "2.3.1",
"version": "3.0.0",
"homepage": "https://github.com/micromatch/picomatch",
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
"funding": "https://github.com/sponsors/jonschlinkert",
Expand Down
4 changes: 2 additions & 2 deletions test/dotfiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ describe('dotfiles', () => {
assert(isMatch('abc/../abc', '*/../*'));
});

it('should not match double dots when not defined in pattern', async() => {
it('should not match double dots when not defined in pattern', async () => {
assert(!isMatch('../abc', '**/*'));
assert(!isMatch('../abc', '**/**/**'));
assert(!isMatch('../abc', '**/**/abc'));
Expand Down Expand Up @@ -291,7 +291,7 @@ describe('dotfiles', () => {
assert(!isMatch('abc/abc/..', 'abc/*/**/*', { strictSlashes: true }));
});

it('should not match single exclusive dots when not defined in pattern', async() => {
it('should not match single exclusive dots when not defined in pattern', async () => {
assert(!isMatch('.', '**'));
assert(!isMatch('abc/./abc', '**'));
assert(!isMatch('abc/abc/.', '**'));
Expand Down
2 changes: 1 addition & 1 deletion test/special-characters.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ describe('special characters', () => {
assert(isMatch('foo(bar)baz', 'foo*baz'));
});

it('should match literal parens with brackets', async() => {
it('should match literal parens with brackets', async () => {
assert(isMatch('foo(bar)baz', 'foo[bar()]+baz'));
});

Expand Down

0 comments on commit bc719c4

Please sign in to comment.