Skip to content

Commit

Permalink
Merge pull request #124 from gwsbhqt/feat/browser-compat
Browse files Browse the repository at this point in the history
feat: compatible browser environment
  • Loading branch information
jonschlinkert committed Feb 8, 2024
2 parents 24fdd65 + b0ff9b1 commit 4bc439e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
/*global navigator*/

'use strict';

const os = require('os');
const pico = require('./lib/picomatch');

const isWindows = os.platform() === 'win32';
function isWindows() {
if (typeof navigator !== 'undefined' && navigator.platform) {
return navigator.platform.toLowerCase().indexOf('win') !== -1;
} else if (typeof process !== 'undefined' && process.platform) {
return process.platform.toLowerCase().indexOf('win') !== -1;
} else return false;
}

const windows = isWindows();

function picomatch(glob, options, returnState = false) {
// default to os.platform()
if (options && (options.windows === null || options.windows === undefined)) {
// don't mutate the original options object
options = { ...options, windows: isWindows };
options = { ...options, windows };
}
return pico(glob, options, returnState);
}
Expand Down

0 comments on commit 4bc439e

Please sign in to comment.