Skip to content

Commit

Permalink
move isWindows to utils
Browse files Browse the repository at this point in the history
  • Loading branch information
jonschlinkert committed Mar 28, 2024
1 parent 6ce95f5 commit f7751de
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
18 changes: 2 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,13 @@
/*global navigator*/

'use strict';

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

const isWindows = () => {
if (typeof navigator !== 'undefined' && navigator.platform) {
const platform = navigator.platform.toLowerCase();
return platform === 'win32' || platform === 'windows';
}

if (typeof process !== 'undefined' && process.platform) {
return process.platform === 'win32';
}

return false;
};
const utils = require('./lib/utils');

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: utils.isWindows() };
}

return pico(glob, options, returnState);
Expand Down
14 changes: 14 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*global navigator*/
'use strict';

const {
Expand All @@ -13,6 +14,19 @@ exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str);
exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
exports.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/');

exports.isWindows = () => {
if (typeof navigator !== 'undefined' && navigator.platform) {
const platform = navigator.platform.toLowerCase();
return platform === 'win32' || platform === 'windows';
}

if (typeof process !== 'undefined' && process.platform) {
return process.platform === 'win32';
}

return false;
};

exports.removeBackslashes = str => {
return str.replace(REGEX_REMOVE_BACKSLASH, match => {
return match === '\\' ? '' : match;
Expand Down

0 comments on commit f7751de

Please sign in to comment.