1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.convertPosixPathToPattern = exports.convertWindowsPathToPattern = exports.convertPathToPattern = exports.escapePosixPath = exports.escapeWindowsPath = exports.escape = exports.removeLeadingDotSegment = exports.makeAbsolute = exports.unixify = void 0;
- const os = require("os");
- const path = require("path");
- const IS_WINDOWS_PLATFORM = os.platform() === 'win32';
- const LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2;
- const POSIX_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\()|\\(?![!()*+?@[\]{|}]))/g;
- const WINDOWS_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()[\]{}]|^!|[!+@](?=\())/g;
- const DOS_DEVICE_PATH_RE = /^\\\\([.?])/;
- const WINDOWS_BACKSLASHES_RE = /\\(?![!()+@[\]{}])/g;
- function unixify(filepath) {
- return filepath.replace(/\\/g, '/');
- }
- exports.unixify = unixify;
- function makeAbsolute(cwd, filepath) {
- return path.resolve(cwd, filepath);
- }
- exports.makeAbsolute = makeAbsolute;
- function removeLeadingDotSegment(entry) {
-
-
- if (entry.charAt(0) === '.') {
- const secondCharactery = entry.charAt(1);
- if (secondCharactery === '/' || secondCharactery === '\\') {
- return entry.slice(LEADING_DOT_SEGMENT_CHARACTERS_COUNT);
- }
- }
- return entry;
- }
- exports.removeLeadingDotSegment = removeLeadingDotSegment;
- exports.escape = IS_WINDOWS_PLATFORM ? escapeWindowsPath : escapePosixPath;
- function escapeWindowsPath(pattern) {
- return pattern.replace(WINDOWS_UNESCAPED_GLOB_SYMBOLS_RE, '\\$2');
- }
- exports.escapeWindowsPath = escapeWindowsPath;
- function escapePosixPath(pattern) {
- return pattern.replace(POSIX_UNESCAPED_GLOB_SYMBOLS_RE, '\\$2');
- }
- exports.escapePosixPath = escapePosixPath;
- exports.convertPathToPattern = IS_WINDOWS_PLATFORM ? convertWindowsPathToPattern : convertPosixPathToPattern;
- function convertWindowsPathToPattern(filepath) {
- return escapeWindowsPath(filepath)
- .replace(DOS_DEVICE_PATH_RE, '//$1')
- .replace(WINDOWS_BACKSLASHES_RE, '/');
- }
- exports.convertWindowsPathToPattern = convertWindowsPathToPattern;
- function convertPosixPathToPattern(filepath) {
- return escapePosixPath(filepath);
- }
- exports.convertPosixPathToPattern = convertPosixPathToPattern;
|