🔧
This commit is contained in:
42
node_modules/picomatch/lib/utils.js
generated
vendored
42
node_modules/picomatch/lib/utils.js
generated
vendored
@@ -1,7 +1,6 @@
|
||||
/*global navigator*/
|
||||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
const win32 = process.platform === 'win32';
|
||||
const {
|
||||
REGEX_BACKSLASH,
|
||||
REGEX_REMOVE_BACKSLASH,
|
||||
@@ -15,27 +14,25 @@ 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;
|
||||
});
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
exports.isWindows = options => {
|
||||
if (options && typeof options.windows === 'boolean') {
|
||||
return options.windows;
|
||||
}
|
||||
return win32 === true || path.sep === '\\';
|
||||
};
|
||||
|
||||
exports.escapeLast = (input, char, lastIdx) => {
|
||||
const idx = input.lastIndexOf(char, lastIdx);
|
||||
if (idx === -1) return input;
|
||||
@@ -62,3 +59,14 @@ exports.wrapOutput = (input, state = {}, options = {}) => {
|
||||
}
|
||||
return output;
|
||||
};
|
||||
|
||||
exports.basename = (path, { windows } = {}) => {
|
||||
const segs = path.split(windows ? /[\\/]/ : '/');
|
||||
const last = segs[segs.length - 1];
|
||||
|
||||
if (last === '') {
|
||||
return segs[segs.length - 2];
|
||||
}
|
||||
|
||||
return last;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user