1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324 |
- 'use strict';
- function assertPath(path) {
- if (typeof path !== "string") {
- throw new TypeError(`Path must be a string, received "${JSON.stringify(path)}"`);
- }
- }
- function stripSuffix(name, suffix) {
- if (suffix.length >= name.length) {
- return name;
- }
- const lenDiff = name.length - suffix.length;
- for(let i = suffix.length - 1; i >= 0; --i){
- if (name.charCodeAt(lenDiff + i) !== suffix.charCodeAt(i)) {
- return name;
- }
- }
- return name.slice(0, -suffix.length);
- }
- function lastPathSegment(path, isSep, start = 0) {
- let matchedNonSeparator = false;
- let end = path.length;
- for(let i = path.length - 1; i >= start; --i){
- if (isSep(path.charCodeAt(i))) {
- if (matchedNonSeparator) {
- start = i + 1;
- break;
- }
- } else if (!matchedNonSeparator) {
- matchedNonSeparator = true;
- end = i + 1;
- }
- }
- return path.slice(start, end);
- }
- function assertArgs$1(path, suffix) {
- assertPath(path);
- if (path.length === 0) return path;
- if (typeof suffix !== "string") {
- throw new TypeError(`Suffix must be a string, received "${JSON.stringify(suffix)}"`);
- }
- }
- function stripTrailingSeparators(segment, isSep) {
- if (segment.length <= 1) {
- return segment;
- }
- let end = segment.length;
- for(let i = segment.length - 1; i > 0; i--){
- if (isSep(segment.charCodeAt(i))) {
- end = i;
- } else {
- break;
- }
- }
- return segment.slice(0, end);
- }
- const CHAR_DOT = 46;
- const CHAR_FORWARD_SLASH = 47;
- function isPosixPathSeparator(code) {
- return code === CHAR_FORWARD_SLASH;
- }
- function basename(path, suffix = "") {
- assertArgs$1(path, suffix);
- const lastSegment = lastPathSegment(path, isPosixPathSeparator);
- const strippedSegment = stripTrailingSeparators(lastSegment, isPosixPathSeparator);
- return suffix ? stripSuffix(strippedSegment, suffix) : strippedSegment;
- }
- const DELIMITER = ":";
- const SEPARATOR = "/";
- const SEPARATOR_PATTERN = /\/+/;
- function assertArg$3(path) {
- assertPath(path);
- if (path.length === 0) return ".";
- }
- function dirname(path) {
- assertArg$3(path);
- let end = -1;
- let matchedNonSeparator = false;
- for(let i = path.length - 1; i >= 1; --i){
- if (isPosixPathSeparator(path.charCodeAt(i))) {
- if (matchedNonSeparator) {
- end = i;
- break;
- }
- } else {
- matchedNonSeparator = true;
- }
- }
-
-
-
-
-
-
-
- if (end === -1) {
- return isPosixPathSeparator(path.charCodeAt(0)) ? "/" : ".";
- }
- return stripTrailingSeparators(path.slice(0, end), isPosixPathSeparator);
- }
- function extname(path) {
- assertPath(path);
- let startDot = -1;
- let startPart = 0;
- let end = -1;
- let matchedSlash = true;
-
-
- let preDotState = 0;
- for(let i = path.length - 1; i >= 0; --i){
- const code = path.charCodeAt(i);
- if (isPosixPathSeparator(code)) {
-
-
- if (!matchedSlash) {
- startPart = i + 1;
- break;
- }
- continue;
- }
- if (end === -1) {
-
-
- matchedSlash = false;
- end = i + 1;
- }
- if (code === CHAR_DOT) {
-
- if (startDot === -1) startDot = i;
- else if (preDotState !== 1) preDotState = 1;
- } else if (startDot !== -1) {
-
-
- preDotState = -1;
- }
- }
- if (startDot === -1 || end === -1 ||
- preDotState === 0 ||
- preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
- return "";
- }
- return path.slice(startDot, end);
- }
- function _format(sep, pathObject) {
- const dir = pathObject.dir || pathObject.root;
- const base = pathObject.base || (pathObject.name ?? "") + (pathObject.ext ?? "");
- if (!dir) return base;
- if (base === sep) return dir;
- if (dir === pathObject.root) return dir + base;
- return dir + sep + base;
- }
- function assertArg$2(pathObject) {
- if (pathObject === null || typeof pathObject !== "object") {
- throw new TypeError(`The "pathObject" argument must be of type Object, received type "${typeof pathObject}"`);
- }
- }
- function format(pathObject) {
- assertArg$2(pathObject);
- return _format("/", pathObject);
- }
- function assertArg$1(url) {
- url = url instanceof URL ? url : new URL(url);
- if (url.protocol !== "file:") {
- throw new TypeError(`URL must be a file URL: received "${url.protocol}"`);
- }
- return url;
- }
- function fromFileUrl(url) {
- url = assertArg$1(url);
- return decodeURIComponent(url.pathname.replace(/%(?![0-9A-Fa-f]{2})/g, "%25"));
- }
- function isAbsolute(path) {
- assertPath(path);
- return path.length > 0 && isPosixPathSeparator(path.charCodeAt(0));
- }
- function assertArg(path) {
- assertPath(path);
- if (path.length === 0) return ".";
- }
- function normalizeString(path, allowAboveRoot, separator, isPathSeparator) {
- let res = "";
- let lastSegmentLength = 0;
- let lastSlash = -1;
- let dots = 0;
- let code;
- for(let i = 0; i <= path.length; ++i){
- if (i < path.length) code = path.charCodeAt(i);
- else if (isPathSeparator(code)) break;
- else code = CHAR_FORWARD_SLASH;
- if (isPathSeparator(code)) {
- if (lastSlash === i - 1 || dots === 1) ; else if (lastSlash !== i - 1 && dots === 2) {
- if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== CHAR_DOT || res.charCodeAt(res.length - 2) !== CHAR_DOT) {
- if (res.length > 2) {
- const lastSlashIndex = res.lastIndexOf(separator);
- if (lastSlashIndex === -1) {
- res = "";
- lastSegmentLength = 0;
- } else {
- res = res.slice(0, lastSlashIndex);
- lastSegmentLength = res.length - 1 - res.lastIndexOf(separator);
- }
- lastSlash = i;
- dots = 0;
- continue;
- } else if (res.length === 2 || res.length === 1) {
- res = "";
- lastSegmentLength = 0;
- lastSlash = i;
- dots = 0;
- continue;
- }
- }
- if (allowAboveRoot) {
- if (res.length > 0) res += `${separator}..`;
- else res = "..";
- lastSegmentLength = 2;
- }
- } else {
- if (res.length > 0) res += separator + path.slice(lastSlash + 1, i);
- else res = path.slice(lastSlash + 1, i);
- lastSegmentLength = i - lastSlash - 1;
- }
- lastSlash = i;
- dots = 0;
- } else if (code === CHAR_DOT && dots !== -1) {
- ++dots;
- } else {
- dots = -1;
- }
- }
- return res;
- }
- function normalize(path) {
- assertArg(path);
- const isAbsolute = isPosixPathSeparator(path.charCodeAt(0));
- const trailingSeparator = isPosixPathSeparator(path.charCodeAt(path.length - 1));
-
- path = normalizeString(path, !isAbsolute, "/", isPosixPathSeparator);
- if (path.length === 0 && !isAbsolute) path = ".";
- if (path.length > 0 && trailingSeparator) path += "/";
- if (isAbsolute) return `/${path}`;
- return path;
- }
- function join(...paths) {
- if (paths.length === 0) return ".";
- paths.forEach((path)=>assertPath(path));
- const joined = paths.filter((path)=>path.length > 0).join("/");
- return joined === "" ? "." : normalize(joined);
- }
- function parse(path) {
- assertPath(path);
- const ret = {
- root: "",
- dir: "",
- base: "",
- ext: "",
- name: ""
- };
- if (path.length === 0) return ret;
- const isAbsolute = isPosixPathSeparator(path.charCodeAt(0));
- let start;
- if (isAbsolute) {
- ret.root = "/";
- start = 1;
- } else {
- start = 0;
- }
- let startDot = -1;
- let startPart = 0;
- let end = -1;
- let matchedSlash = true;
- let i = path.length - 1;
-
-
- let preDotState = 0;
-
- for(; i >= start; --i){
- const code = path.charCodeAt(i);
- if (isPosixPathSeparator(code)) {
-
-
- if (!matchedSlash) {
- startPart = i + 1;
- break;
- }
- continue;
- }
- if (end === -1) {
-
-
- matchedSlash = false;
- end = i + 1;
- }
- if (code === CHAR_DOT) {
-
- if (startDot === -1) startDot = i;
- else if (preDotState !== 1) preDotState = 1;
- } else if (startDot !== -1) {
-
-
- preDotState = -1;
- }
- }
- if (startDot === -1 || end === -1 ||
- preDotState === 0 ||
- preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
- if (end !== -1) {
- if (startPart === 0 && isAbsolute) {
- ret.base = ret.name = path.slice(1, end);
- } else {
- ret.base = ret.name = path.slice(startPart, end);
- }
- }
-
- ret.base = ret.base || "/";
- } else {
- if (startPart === 0 && isAbsolute) {
- ret.name = path.slice(1, startDot);
- ret.base = path.slice(1, end);
- } else {
- ret.name = path.slice(startPart, startDot);
- ret.base = path.slice(startPart, end);
- }
- ret.ext = path.slice(startDot, end);
- }
- if (startPart > 0) {
- ret.dir = stripTrailingSeparators(path.slice(0, startPart - 1), isPosixPathSeparator);
- } else if (isAbsolute) ret.dir = "/";
- return ret;
- }
- function resolve(...pathSegments) {
- let resolvedPath = "";
- let resolvedAbsolute = false;
- for(let i = pathSegments.length - 1; i >= -1 && !resolvedAbsolute; i--){
- let path;
- if (i >= 0) path = pathSegments[i];
- else {
-
- const { Deno } = globalThis;
- if (typeof Deno?.cwd !== "function") {
- throw new TypeError("Resolved a relative path without a current working directory (CWD)");
- }
- path = Deno.cwd();
- }
- assertPath(path);
-
- if (path.length === 0) {
- continue;
- }
- resolvedPath = `${path}/${resolvedPath}`;
- resolvedAbsolute = isPosixPathSeparator(path.charCodeAt(0));
- }
-
-
-
- resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute, "/", isPosixPathSeparator);
- if (resolvedAbsolute) {
- if (resolvedPath.length > 0) return `/${resolvedPath}`;
- else return "/";
- } else if (resolvedPath.length > 0) return resolvedPath;
- else return ".";
- }
- function assertArgs(from, to) {
- assertPath(from);
- assertPath(to);
- if (from === to) return "";
- }
- function relative(from, to) {
- assertArgs(from, to);
- from = resolve(from);
- to = resolve(to);
- if (from === to) return "";
-
- let fromStart = 1;
- const fromEnd = from.length;
- for(; fromStart < fromEnd; ++fromStart){
- if (!isPosixPathSeparator(from.charCodeAt(fromStart))) break;
- }
- const fromLen = fromEnd - fromStart;
-
- let toStart = 1;
- const toEnd = to.length;
- for(; toStart < toEnd; ++toStart){
- if (!isPosixPathSeparator(to.charCodeAt(toStart))) break;
- }
- const toLen = toEnd - toStart;
-
- const length = fromLen < toLen ? fromLen : toLen;
- let lastCommonSep = -1;
- let i = 0;
- for(; i <= length; ++i){
- if (i === length) {
- if (toLen > length) {
- if (isPosixPathSeparator(to.charCodeAt(toStart + i))) {
-
-
- return to.slice(toStart + i + 1);
- } else if (i === 0) {
-
-
- return to.slice(toStart + i);
- }
- } else if (fromLen > length) {
- if (isPosixPathSeparator(from.charCodeAt(fromStart + i))) {
-
-
- lastCommonSep = i;
- } else if (i === 0) {
-
-
- lastCommonSep = 0;
- }
- }
- break;
- }
- const fromCode = from.charCodeAt(fromStart + i);
- const toCode = to.charCodeAt(toStart + i);
- if (fromCode !== toCode) break;
- else if (isPosixPathSeparator(fromCode)) lastCommonSep = i;
- }
- let out = "";
-
-
- for(i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i){
- if (i === fromEnd || isPosixPathSeparator(from.charCodeAt(i))) {
- if (out.length === 0) out += "..";
- else out += "/..";
- }
- }
-
-
- if (out.length > 0) return out + to.slice(toStart + lastCommonSep);
- else {
- toStart += lastCommonSep;
- if (isPosixPathSeparator(to.charCodeAt(toStart))) ++toStart;
- return to.slice(toStart);
- }
- }
- const WHITESPACE_ENCODINGS = {
- "\u0009": "%09",
- "\u000A": "%0A",
- "\u000B": "%0B",
- "\u000C": "%0C",
- "\u000D": "%0D",
- "\u0020": "%20"
- };
- function encodeWhitespace(string) {
- return string.replaceAll(/[\s]/g, (c)=>{
- return WHITESPACE_ENCODINGS[c] ?? c;
- });
- }
- function toFileUrl(path) {
- if (!isAbsolute(path)) {
- throw new TypeError(`Path must be absolute: received "${path}"`);
- }
- const url = new URL("file:///");
- url.pathname = encodeWhitespace(path.replace(/%/g, "%25").replace(/\\/g, "%5C"));
- return url;
- }
- function toNamespacedPath(path) {
-
- return path;
- }
- function common$1(paths, sep) {
- const [first = "", ...remaining] = paths;
- const parts = first.split(sep);
- let endOfPrefix = parts.length;
- let append = "";
- for (const path of remaining){
- const compare = path.split(sep);
- if (compare.length <= endOfPrefix) {
- endOfPrefix = compare.length;
- append = "";
- }
- for(let i = 0; i < endOfPrefix; i++){
- if (compare[i] !== parts[i]) {
- endOfPrefix = i;
- append = i === 0 ? "" : sep;
- break;
- }
- }
- }
- return parts.slice(0, endOfPrefix).join(sep) + append;
- }
- function common(paths) {
- return common$1(paths, SEPARATOR);
- }
- const REG_EXP_ESCAPE_CHARS = [
- "!",
- "$",
- "(",
- ")",
- "*",
- "+",
- ".",
- "=",
- "?",
- "[",
- "\\",
- "^",
- "{",
- "|"
- ];
- const RANGE_ESCAPE_CHARS = [
- "-",
- "\\",
- "]"
- ];
- function _globToRegExp(c, glob, { extended = true, globstar: globstarOption = true,
- caseInsensitive = false } = {}) {
- if (glob === "") {
- return /(?!)/;
- }
-
- let newLength = glob.length;
- for(; newLength > 1 && c.seps.includes(glob[newLength - 1]); newLength--);
- glob = glob.slice(0, newLength);
- let regExpString = "";
-
- for(let j = 0; j < glob.length;){
- let segment = "";
- const groupStack = [];
- let inRange = false;
- let inEscape = false;
- let endsWithSep = false;
- let i = j;
-
- for(; i < glob.length && !c.seps.includes(glob[i]); i++){
- if (inEscape) {
- inEscape = false;
- const escapeChars = inRange ? RANGE_ESCAPE_CHARS : REG_EXP_ESCAPE_CHARS;
- segment += escapeChars.includes(glob[i]) ? `\\${glob[i]}` : glob[i];
- continue;
- }
- if (glob[i] === c.escapePrefix) {
- inEscape = true;
- continue;
- }
- if (glob[i] === "[") {
- if (!inRange) {
- inRange = true;
- segment += "[";
- if (glob[i + 1] === "!") {
- i++;
- segment += "^";
- } else if (glob[i + 1] === "^") {
- i++;
- segment += "\\^";
- }
- continue;
- } else if (glob[i + 1] === ":") {
- let k = i + 1;
- let value = "";
- while(glob[k + 1] !== undefined && glob[k + 1] !== ":"){
- value += glob[k + 1];
- k++;
- }
- if (glob[k + 1] === ":" && glob[k + 2] === "]") {
- i = k + 2;
- if (value === "alnum") segment += "\\dA-Za-z";
- else if (value === "alpha") segment += "A-Za-z";
- else if (value === "ascii") segment += "\x00-\x7F";
- else if (value === "blank") segment += "\t ";
- else if (value === "cntrl") segment += "\x00-\x1F\x7F";
- else if (value === "digit") segment += "\\d";
- else if (value === "graph") segment += "\x21-\x7E";
- else if (value === "lower") segment += "a-z";
- else if (value === "print") segment += "\x20-\x7E";
- else if (value === "punct") {
- segment += "!\"#$%&'()*+,\\-./:;<=>?@[\\\\\\]^_‘{|}~";
- } else if (value === "space") segment += "\\s\v";
- else if (value === "upper") segment += "A-Z";
- else if (value === "word") segment += "\\w";
- else if (value === "xdigit") segment += "\\dA-Fa-f";
- continue;
- }
- }
- }
- if (glob[i] === "]" && inRange) {
- inRange = false;
- segment += "]";
- continue;
- }
- if (inRange) {
- segment += glob[i];
- continue;
- }
- if (glob[i] === ")" && groupStack.length > 0 && groupStack[groupStack.length - 1] !== "BRACE") {
- segment += ")";
- const type = groupStack.pop();
- if (type === "!") {
- segment += c.wildcard;
- } else if (type !== "@") {
- segment += type;
- }
- continue;
- }
- if (glob[i] === "|" && groupStack.length > 0 && groupStack[groupStack.length - 1] !== "BRACE") {
- segment += "|";
- continue;
- }
- if (glob[i] === "+" && extended && glob[i + 1] === "(") {
- i++;
- groupStack.push("+");
- segment += "(?:";
- continue;
- }
- if (glob[i] === "@" && extended && glob[i + 1] === "(") {
- i++;
- groupStack.push("@");
- segment += "(?:";
- continue;
- }
- if (glob[i] === "?") {
- if (extended && glob[i + 1] === "(") {
- i++;
- groupStack.push("?");
- segment += "(?:";
- } else {
- segment += ".";
- }
- continue;
- }
- if (glob[i] === "!" && extended && glob[i + 1] === "(") {
- i++;
- groupStack.push("!");
- segment += "(?!";
- continue;
- }
- if (glob[i] === "{") {
- groupStack.push("BRACE");
- segment += "(?:";
- continue;
- }
- if (glob[i] === "}" && groupStack[groupStack.length - 1] === "BRACE") {
- groupStack.pop();
- segment += ")";
- continue;
- }
- if (glob[i] === "," && groupStack[groupStack.length - 1] === "BRACE") {
- segment += "|";
- continue;
- }
- if (glob[i] === "*") {
- if (extended && glob[i + 1] === "(") {
- i++;
- groupStack.push("*");
- segment += "(?:";
- } else {
- const prevChar = glob[i - 1];
- let numStars = 1;
- while(glob[i + 1] === "*"){
- i++;
- numStars++;
- }
- const nextChar = glob[i + 1];
- if (globstarOption && numStars === 2 && [
- ...c.seps,
- undefined
- ].includes(prevChar) && [
- ...c.seps,
- undefined
- ].includes(nextChar)) {
- segment += c.globstar;
- endsWithSep = true;
- } else {
- segment += c.wildcard;
- }
- }
- continue;
- }
- segment += REG_EXP_ESCAPE_CHARS.includes(glob[i]) ? `\\${glob[i]}` : glob[i];
- }
-
- if (groupStack.length > 0 || inRange || inEscape) {
-
- segment = "";
- for (const c of glob.slice(j, i)){
- segment += REG_EXP_ESCAPE_CHARS.includes(c) ? `\\${c}` : c;
- endsWithSep = false;
- }
- }
- regExpString += segment;
- if (!endsWithSep) {
- regExpString += i < glob.length ? c.sep : c.sepMaybe;
- endsWithSep = true;
- }
-
- while(c.seps.includes(glob[i]))i++;
- j = i;
- }
- regExpString = `^${regExpString}$`;
- return new RegExp(regExpString, caseInsensitive ? "i" : "");
- }
- const constants = {
- sep: "/+",
- sepMaybe: "/*",
- seps: [
- "/"
- ],
- globstar: "(?:[^/]*(?:/|$)+)*",
- wildcard: "[^/]*",
- escapePrefix: "\\"
- };
- function globToRegExp(glob, options = {}) {
- return _globToRegExp(constants, glob, options);
- }
- function isGlob(str) {
- const chars = {
- "{": "}",
- "(": ")",
- "[": "]"
- };
- const regex = /\\(.)|(^!|\*|\?|[\].+)]\?|\[[^\\\]]+\]|\{[^\\}]+\}|\(\?[:!=][^\\)]+\)|\([^|]+\|[^\\)]+\))/;
- if (str === "") {
- return false;
- }
- let match;
- while(match = regex.exec(str)){
- if (match[2]) return true;
- let idx = match.index + match[0].length;
-
-
- const open = match[1];
- const close = open ? chars[open] : null;
- if (open && close) {
- const n = str.indexOf(close, idx);
- if (n !== -1) {
- idx = n + 1;
- }
- }
- str = str.slice(idx);
- }
- return false;
- }
- function normalizeGlob(glob, options = {}) {
- const { globstar = false } = options;
- if (glob.match(/\0/g)) {
- throw new Error(`Glob contains invalid characters: "${glob}"`);
- }
- if (!globstar) {
- return normalize(glob);
- }
- const s = SEPARATOR_PATTERN.source;
- const badParentPattern = new RegExp(`(?<=(${s}|^)\\*\\*${s})\\.\\.(?=${s}|$)`, "g");
- return normalize(glob.replace(badParentPattern, "\0")).replace(/\0/g, "..");
- }
- function joinGlobs(globs, options = {}) {
- const { globstar = false } = options;
- if (!globstar || globs.length === 0) {
- return join(...globs);
- }
- let joined;
- for (const glob of globs){
- const path = glob;
- if (path.length > 0) {
- if (!joined) joined = path;
- else joined += `${SEPARATOR}${path}`;
- }
- }
- if (!joined) return ".";
- return normalizeGlob(joined, {
- globstar
- });
- }
- exports.DELIMITER = DELIMITER;
- exports.SEPARATOR = SEPARATOR;
- exports.SEPARATOR_PATTERN = SEPARATOR_PATTERN;
- exports.basename = basename;
- exports.common = common;
- exports.dirname = dirname;
- exports.extname = extname;
- exports.format = format;
- exports.fromFileUrl = fromFileUrl;
- exports.globToRegExp = globToRegExp;
- exports.isAbsolute = isAbsolute;
- exports.isGlob = isGlob;
- exports.join = join;
- exports.joinGlobs = joinGlobs;
- exports.normalize = normalize;
- exports.normalizeGlob = normalizeGlob;
- exports.parse = parse;
- exports.relative = relative;
- exports.resolve = resolve;
- exports.toFileUrl = toFileUrl;
- exports.toNamespacedPath = toNamespacedPath;
|