@goodbyenjn/utils 26.2.0 → 26.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -31
- package/dist/chunks/chunk-3c6f28c7.d.ts +39 -0
- package/dist/chunks/{chunk-5ed3bc8a.js → chunk-486f65b0.js} +190 -324
- package/dist/chunks/chunk-704a1835.d.ts +174 -0
- package/dist/chunks/chunk-7ffde8d4.js +43 -0
- package/dist/chunks/chunk-b61db0a7.js +27 -0
- package/dist/common.d.ts +8 -16
- package/dist/common.js +1 -1
- package/dist/fs.d.ts +2 -5
- package/dist/fs.js +246 -593
- package/dist/global-types.d.ts +89 -59
- package/dist/remeda.d.ts +10 -12288
- package/dist/remeda.js +2 -2
- package/dist/result.d.ts +2 -2
- package/dist/result.js +2 -2
- package/dist/shell.d.ts +4 -14
- package/dist/shell.js +290 -290
- package/dist/types.d.ts +3 -2
- package/package.json +14 -11
- package/dist/chunks/chunk-b970a8d0.js +0 -2782
- package/dist/chunks/chunk-d1860346.d.ts +0 -154
- package/dist/chunks/chunk-e931fe39.d.ts +0 -11978
package/dist/fs.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { i as __toESM, t as __commonJSMin } from "./chunks/chunk-7ffde8d4.js";
|
|
2
|
+
import { Gt as isString, Tt as isArray, pn as omit, zt as isNumber } from "./chunks/chunk-b61db0a7.js";
|
|
3
|
+
import { A as Result, D as safeParse, M as ok, O as stringify, j as err, l as removePrefix } from "./chunks/chunk-486f65b0.js";
|
|
3
4
|
import * as nativeFs$1 from "fs";
|
|
4
5
|
import nativeFs from "fs";
|
|
5
6
|
import path, { basename, dirname, normalize, posix, relative, resolve, sep } from "path";
|
|
@@ -9,27 +10,27 @@ import fs, { promises } from "node:fs";
|
|
|
9
10
|
import path$1, { dirname as dirname$1 } from "node:path";
|
|
10
11
|
|
|
11
12
|
//#region node_modules/.pnpm/fdir@6.5.0_picomatch@4.0.3/node_modules/fdir/dist/index.mjs
|
|
12
|
-
var __require =
|
|
13
|
-
function cleanPath(path
|
|
14
|
-
let normalized = normalize(path
|
|
13
|
+
var __require = createRequire(import.meta.url);
|
|
14
|
+
function cleanPath(path) {
|
|
15
|
+
let normalized = normalize(path);
|
|
15
16
|
if (normalized.length > 1 && normalized[normalized.length - 1] === sep) normalized = normalized.substring(0, normalized.length - 1);
|
|
16
17
|
return normalized;
|
|
17
18
|
}
|
|
18
19
|
const SLASHES_REGEX = /[\\/]/g;
|
|
19
|
-
function convertSlashes(path
|
|
20
|
-
return path
|
|
20
|
+
function convertSlashes(path, separator) {
|
|
21
|
+
return path.replace(SLASHES_REGEX, separator);
|
|
21
22
|
}
|
|
22
23
|
const WINDOWS_ROOT_DIR_REGEX = /^[a-z]:[\\/]$/i;
|
|
23
|
-
function isRootDirectory(path
|
|
24
|
-
return path
|
|
24
|
+
function isRootDirectory(path) {
|
|
25
|
+
return path === "/" || WINDOWS_ROOT_DIR_REGEX.test(path);
|
|
25
26
|
}
|
|
26
|
-
function normalizePath(path
|
|
27
|
+
function normalizePath(path, options) {
|
|
27
28
|
const { resolvePaths, normalizePath: normalizePath$1, pathSeparator } = options;
|
|
28
|
-
const pathNeedsCleaning = process.platform === "win32" && path
|
|
29
|
-
if (resolvePaths) path
|
|
30
|
-
if (normalizePath$1 || pathNeedsCleaning) path
|
|
31
|
-
if (path
|
|
32
|
-
return convertSlashes(path
|
|
29
|
+
const pathNeedsCleaning = process.platform === "win32" && path.includes("/") || path.startsWith(".");
|
|
30
|
+
if (resolvePaths) path = resolve(path);
|
|
31
|
+
if (normalizePath$1 || pathNeedsCleaning) path = cleanPath(path);
|
|
32
|
+
if (path === ".") return "";
|
|
33
|
+
return convertSlashes(path[path.length - 1] !== pathSeparator ? path + pathSeparator : path, pathSeparator);
|
|
33
34
|
}
|
|
34
35
|
function joinPathWithBasePath(filename, directoryPath) {
|
|
35
36
|
return directoryPath + filename;
|
|
@@ -65,8 +66,8 @@ const pushDirectory = (directoryPath, paths) => {
|
|
|
65
66
|
paths.push(directoryPath || ".");
|
|
66
67
|
};
|
|
67
68
|
const pushDirectoryFilter = (directoryPath, paths, filters) => {
|
|
68
|
-
const path
|
|
69
|
-
if (filters.every((filter) => filter(path
|
|
69
|
+
const path = directoryPath || ".";
|
|
70
|
+
if (filters.every((filter) => filter(path, true))) paths.push(path);
|
|
70
71
|
};
|
|
71
72
|
const empty$2 = () => {};
|
|
72
73
|
function build$6(root, options) {
|
|
@@ -115,45 +116,45 @@ const empty = () => {};
|
|
|
115
116
|
function build$3(options) {
|
|
116
117
|
return options.group ? groupFiles : empty;
|
|
117
118
|
}
|
|
118
|
-
const resolveSymlinksAsync = function(path
|
|
119
|
-
const { queue, fs
|
|
119
|
+
const resolveSymlinksAsync = function(path, state, callback$1) {
|
|
120
|
+
const { queue, fs, options: { suppressErrors } } = state;
|
|
120
121
|
queue.enqueue();
|
|
121
|
-
fs
|
|
122
|
+
fs.realpath(path, (error, resolvedPath) => {
|
|
122
123
|
if (error) return queue.dequeue(suppressErrors ? null : error, state);
|
|
123
|
-
fs
|
|
124
|
+
fs.stat(resolvedPath, (error$1, stat) => {
|
|
124
125
|
if (error$1) return queue.dequeue(suppressErrors ? null : error$1, state);
|
|
125
|
-
if (stat.isDirectory() && isRecursive(path
|
|
126
|
+
if (stat.isDirectory() && isRecursive(path, resolvedPath, state)) return queue.dequeue(null, state);
|
|
126
127
|
callback$1(stat, resolvedPath);
|
|
127
128
|
queue.dequeue(null, state);
|
|
128
129
|
});
|
|
129
130
|
});
|
|
130
131
|
};
|
|
131
|
-
const resolveSymlinks = function(path
|
|
132
|
-
const { queue, fs
|
|
132
|
+
const resolveSymlinks = function(path, state, callback$1) {
|
|
133
|
+
const { queue, fs, options: { suppressErrors } } = state;
|
|
133
134
|
queue.enqueue();
|
|
134
135
|
try {
|
|
135
|
-
const resolvedPath = fs
|
|
136
|
-
const stat = fs
|
|
137
|
-
if (stat.isDirectory() && isRecursive(path
|
|
136
|
+
const resolvedPath = fs.realpathSync(path);
|
|
137
|
+
const stat = fs.statSync(resolvedPath);
|
|
138
|
+
if (stat.isDirectory() && isRecursive(path, resolvedPath, state)) return;
|
|
138
139
|
callback$1(stat, resolvedPath);
|
|
139
|
-
} catch (e
|
|
140
|
-
if (!suppressErrors) throw e
|
|
140
|
+
} catch (e) {
|
|
141
|
+
if (!suppressErrors) throw e;
|
|
141
142
|
}
|
|
142
143
|
};
|
|
143
144
|
function build$2(options, isSynchronous) {
|
|
144
145
|
if (!options.resolveSymlinks || options.excludeSymlinks) return null;
|
|
145
146
|
return isSynchronous ? resolveSymlinks : resolveSymlinksAsync;
|
|
146
147
|
}
|
|
147
|
-
function isRecursive(path
|
|
148
|
+
function isRecursive(path, resolved, state) {
|
|
148
149
|
if (state.options.useRealPaths) return isRecursiveUsingRealPaths(resolved, state);
|
|
149
|
-
let parent = dirname(path
|
|
150
|
+
let parent = dirname(path);
|
|
150
151
|
let depth = 1;
|
|
151
152
|
while (parent !== state.root && depth < 2) {
|
|
152
153
|
const resolvedPath = state.symlinks.get(parent);
|
|
153
154
|
if (!!resolvedPath && (resolvedPath === resolved || resolvedPath.startsWith(resolved) || resolved.startsWith(resolvedPath))) depth++;
|
|
154
155
|
else parent = dirname(parent);
|
|
155
156
|
}
|
|
156
|
-
state.symlinks.set(path
|
|
157
|
+
state.symlinks.set(path, resolved);
|
|
157
158
|
return depth > 1;
|
|
158
159
|
}
|
|
159
160
|
function isRecursiveUsingRealPaths(resolved, state) {
|
|
@@ -202,35 +203,30 @@ const readdirOpts = { withFileTypes: true };
|
|
|
202
203
|
const walkAsync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
|
|
203
204
|
state.queue.enqueue();
|
|
204
205
|
if (currentDepth < 0) return state.queue.dequeue(null, state);
|
|
205
|
-
const { fs
|
|
206
|
+
const { fs } = state;
|
|
206
207
|
state.visited.push(crawlPath);
|
|
207
208
|
state.counts.directories++;
|
|
208
|
-
fs
|
|
209
|
+
fs.readdir(crawlPath || ".", readdirOpts, (error, entries = []) => {
|
|
209
210
|
callback$1(entries, directoryPath, currentDepth);
|
|
210
211
|
state.queue.dequeue(state.options.suppressErrors ? null : error, state);
|
|
211
212
|
});
|
|
212
213
|
};
|
|
213
214
|
const walkSync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
|
|
214
|
-
const { fs
|
|
215
|
+
const { fs } = state;
|
|
215
216
|
if (currentDepth < 0) return;
|
|
216
217
|
state.visited.push(crawlPath);
|
|
217
218
|
state.counts.directories++;
|
|
218
219
|
let entries = [];
|
|
219
220
|
try {
|
|
220
|
-
entries = fs
|
|
221
|
-
} catch (e
|
|
222
|
-
if (!state.options.suppressErrors) throw e
|
|
221
|
+
entries = fs.readdirSync(crawlPath || ".", readdirOpts);
|
|
222
|
+
} catch (e) {
|
|
223
|
+
if (!state.options.suppressErrors) throw e;
|
|
223
224
|
}
|
|
224
225
|
callback$1(entries, directoryPath, currentDepth);
|
|
225
226
|
};
|
|
226
227
|
function build(isSynchronous) {
|
|
227
228
|
return isSynchronous ? walkSync : walkAsync;
|
|
228
229
|
}
|
|
229
|
-
/**
|
|
230
|
-
* This is a custom stateless queue to track concurrent async fs calls.
|
|
231
|
-
* It increments a counter whenever a call is queued and decrements it
|
|
232
|
-
* as soon as it completes. When the counter hits 0, it calls onQueueEmpty.
|
|
233
|
-
*/
|
|
234
230
|
var Queue = class {
|
|
235
231
|
count = 0;
|
|
236
232
|
constructor(onQueueEmpty) {
|
|
@@ -265,18 +261,10 @@ var Counter = class {
|
|
|
265
261
|
get directories() {
|
|
266
262
|
return this._directories;
|
|
267
263
|
}
|
|
268
|
-
/**
|
|
269
|
-
* @deprecated use `directories` instead
|
|
270
|
-
*/
|
|
271
|
-
/* c8 ignore next 3 */
|
|
272
264
|
get dirs() {
|
|
273
265
|
return this._directories;
|
|
274
266
|
}
|
|
275
267
|
};
|
|
276
|
-
/**
|
|
277
|
-
* AbortController is not supported on Node 14 so we use this until we can drop
|
|
278
|
-
* support for Node 14.
|
|
279
|
-
*/
|
|
280
268
|
var Aborter = class {
|
|
281
269
|
aborted = false;
|
|
282
270
|
abort() {
|
|
@@ -306,7 +294,7 @@ var Walker = class {
|
|
|
306
294
|
counts: new Counter(),
|
|
307
295
|
options,
|
|
308
296
|
queue: new Queue((error, state) => this.callbackInvoker(state, error, callback$1)),
|
|
309
|
-
symlinks:
|
|
297
|
+
symlinks: new Map(),
|
|
310
298
|
visited: [""].slice(0, 0),
|
|
311
299
|
controller: new Aborter(),
|
|
312
300
|
fs: options.fs || nativeFs$1
|
|
@@ -334,19 +322,19 @@ var Walker = class {
|
|
|
334
322
|
const filename = this.joinPath(entry.name, directoryPath);
|
|
335
323
|
this.pushFile(filename, files, this.state.counts, filters);
|
|
336
324
|
} else if (entry.isDirectory()) {
|
|
337
|
-
let path
|
|
338
|
-
if (exclude && exclude(entry.name, path
|
|
339
|
-
this.pushDirectory(path
|
|
340
|
-
this.walkDirectory(this.state, path
|
|
325
|
+
let path = joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator);
|
|
326
|
+
if (exclude && exclude(entry.name, path)) continue;
|
|
327
|
+
this.pushDirectory(path, paths, filters);
|
|
328
|
+
this.walkDirectory(this.state, path, path, depth - 1, this.walk);
|
|
341
329
|
} else if (this.resolveSymlink && entry.isSymbolicLink()) {
|
|
342
|
-
let path
|
|
343
|
-
this.resolveSymlink(path
|
|
330
|
+
let path = joinPathWithBasePath(entry.name, directoryPath);
|
|
331
|
+
this.resolveSymlink(path, this.state, (stat, resolvedPath) => {
|
|
344
332
|
if (stat.isDirectory()) {
|
|
345
333
|
resolvedPath = normalizePath(resolvedPath, this.state.options);
|
|
346
|
-
if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path
|
|
347
|
-
this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path
|
|
334
|
+
if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path + pathSeparator)) return;
|
|
335
|
+
this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path + pathSeparator, depth - 1, this.walk);
|
|
348
336
|
} else {
|
|
349
|
-
resolvedPath = useRealPaths ? resolvedPath : path
|
|
337
|
+
resolvedPath = useRealPaths ? resolvedPath : path;
|
|
350
338
|
const filename = basename(resolvedPath);
|
|
351
339
|
const directoryPath$1 = normalizePath(dirname(resolvedPath), this.state.options);
|
|
352
340
|
resolvedPath = this.joinPath(filename, directoryPath$1);
|
|
@@ -359,10 +347,10 @@ var Walker = class {
|
|
|
359
347
|
};
|
|
360
348
|
};
|
|
361
349
|
function promise(root, options) {
|
|
362
|
-
return new Promise((resolve$1
|
|
363
|
-
callback(root, options, (err
|
|
364
|
-
if (err
|
|
365
|
-
resolve$1
|
|
350
|
+
return new Promise((resolve$1, reject) => {
|
|
351
|
+
callback(root, options, (err, output) => {
|
|
352
|
+
if (err) return reject(err);
|
|
353
|
+
resolve$1(output);
|
|
366
354
|
});
|
|
367
355
|
});
|
|
368
356
|
}
|
|
@@ -388,7 +376,6 @@ var APIBuilder = class {
|
|
|
388
376
|
}
|
|
389
377
|
};
|
|
390
378
|
let pm = null;
|
|
391
|
-
/* c8 ignore next 6 */
|
|
392
379
|
try {
|
|
393
380
|
__require.resolve("picomatch");
|
|
394
381
|
pm = __require("picomatch");
|
|
@@ -483,14 +470,6 @@ var Builder = class {
|
|
|
483
470
|
this.globFunction = fn;
|
|
484
471
|
return this;
|
|
485
472
|
}
|
|
486
|
-
/**
|
|
487
|
-
* @deprecated Pass options using the constructor instead:
|
|
488
|
-
* ```ts
|
|
489
|
-
* new fdir(options).crawl("/path/to/root");
|
|
490
|
-
* ```
|
|
491
|
-
* This method will be removed in v7.0
|
|
492
|
-
*/
|
|
493
|
-
/* c8 ignore next 4 */
|
|
494
473
|
crawlWithOptions(root, options) {
|
|
495
474
|
this.options = {
|
|
496
475
|
...this.options,
|
|
@@ -504,26 +483,22 @@ var Builder = class {
|
|
|
504
483
|
}
|
|
505
484
|
globWithOptions(patterns, ...options) {
|
|
506
485
|
const globFn = this.globFunction || pm;
|
|
507
|
-
/* c8 ignore next 5 */
|
|
508
486
|
if (!globFn) throw new Error("Please specify a glob function to use glob matching.");
|
|
509
487
|
var isMatch = this.globCache[patterns.join("\0")];
|
|
510
488
|
if (!isMatch) {
|
|
511
489
|
isMatch = globFn(patterns, ...options);
|
|
512
490
|
this.globCache[patterns.join("\0")] = isMatch;
|
|
513
491
|
}
|
|
514
|
-
this.options.filters.push((path
|
|
492
|
+
this.options.filters.push((path) => isMatch(path));
|
|
515
493
|
return this;
|
|
516
494
|
}
|
|
517
495
|
};
|
|
518
496
|
|
|
519
497
|
//#endregion
|
|
520
498
|
//#region node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.js
|
|
521
|
-
var require_constants =
|
|
499
|
+
var require_constants = __commonJSMin(((exports, module) => {
|
|
522
500
|
const WIN_SLASH = "\\\\/";
|
|
523
501
|
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
524
|
-
/**
|
|
525
|
-
* Posix glob regex
|
|
526
|
-
*/
|
|
527
502
|
const DOT_LITERAL = "\\.";
|
|
528
503
|
const PLUS_LITERAL = "\\+";
|
|
529
504
|
const QMARK_LITERAL = "\\?";
|
|
@@ -551,9 +526,6 @@ var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
551
526
|
START_ANCHOR,
|
|
552
527
|
SEP: "/"
|
|
553
528
|
};
|
|
554
|
-
/**
|
|
555
|
-
* Windows glob regex
|
|
556
|
-
*/
|
|
557
529
|
const WINDOWS_CHARS = {
|
|
558
530
|
...POSIX_CHARS,
|
|
559
531
|
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
@@ -569,9 +541,6 @@ var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
569
541
|
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
|
|
570
542
|
SEP: "\\"
|
|
571
543
|
};
|
|
572
|
-
/**
|
|
573
|
-
* POSIX Bracket Regex
|
|
574
|
-
*/
|
|
575
544
|
const POSIX_REGEX_SOURCE = {
|
|
576
545
|
alnum: "a-zA-Z0-9",
|
|
577
546
|
alpha: "a-zA-Z",
|
|
@@ -683,7 +652,7 @@ var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
683
652
|
|
|
684
653
|
//#endregion
|
|
685
654
|
//#region node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.js
|
|
686
|
-
var require_utils =
|
|
655
|
+
var require_utils = __commonJSMin(((exports) => {
|
|
687
656
|
const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = require_constants();
|
|
688
657
|
exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
|
|
689
658
|
exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
|
|
@@ -722,8 +691,8 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
722
691
|
if (state.negated === true) output = `(?:^(?!${output}).*$)`;
|
|
723
692
|
return output;
|
|
724
693
|
};
|
|
725
|
-
exports.basename = (path
|
|
726
|
-
const segs = path
|
|
694
|
+
exports.basename = (path, { windows } = {}) => {
|
|
695
|
+
const segs = path.split(windows ? /[\\/]/ : "/");
|
|
727
696
|
const last = segs[segs.length - 1];
|
|
728
697
|
if (last === "") return segs[segs.length - 2];
|
|
729
698
|
return last;
|
|
@@ -732,7 +701,7 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
732
701
|
|
|
733
702
|
//#endregion
|
|
734
703
|
//#region node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/scan.js
|
|
735
|
-
var require_scan =
|
|
704
|
+
var require_scan = __commonJSMin(((exports, module) => {
|
|
736
705
|
const utils = require_utils();
|
|
737
706
|
const { CHAR_ASTERISK, CHAR_AT, CHAR_BACKWARD_SLASH, CHAR_COMMA, CHAR_DOT, CHAR_EXCLAMATION_MARK, CHAR_FORWARD_SLASH, CHAR_LEFT_CURLY_BRACE, CHAR_LEFT_PARENTHESES, CHAR_LEFT_SQUARE_BRACKET, CHAR_PLUS, CHAR_QUESTION_MARK, CHAR_RIGHT_CURLY_BRACE, CHAR_RIGHT_PARENTHESES, CHAR_RIGHT_SQUARE_BRACKET } = require_constants();
|
|
738
707
|
const isPathSeparator = (code) => {
|
|
@@ -741,22 +710,6 @@ var require_scan = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
741
710
|
const depth = (token) => {
|
|
742
711
|
if (token.isPrefix !== true) token.depth = token.isGlobstar ? Infinity : 1;
|
|
743
712
|
};
|
|
744
|
-
/**
|
|
745
|
-
* Quickly scans a glob pattern and returns an object with a handful of
|
|
746
|
-
* useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
|
|
747
|
-
* `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
|
|
748
|
-
* with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
|
|
749
|
-
*
|
|
750
|
-
* ```js
|
|
751
|
-
* const pm = require('picomatch');
|
|
752
|
-
* console.log(pm.scan('foo/bar/*.js'));
|
|
753
|
-
* { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
|
|
754
|
-
* ```
|
|
755
|
-
* @param {String} `str`
|
|
756
|
-
* @param {Object} `options`
|
|
757
|
-
* @return {Object} Returns an object with tokens and regex source string.
|
|
758
|
-
* @api public
|
|
759
|
-
*/
|
|
760
713
|
const scan = (input, options) => {
|
|
761
714
|
const opts = options || {};
|
|
762
715
|
const length = input.length - 1;
|
|
@@ -945,7 +898,7 @@ var require_scan = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
945
898
|
}
|
|
946
899
|
let base = str;
|
|
947
900
|
let prefix = "";
|
|
948
|
-
let glob
|
|
901
|
+
let glob = "";
|
|
949
902
|
if (start > 0) {
|
|
950
903
|
prefix = str.slice(0, start);
|
|
951
904
|
str = str.slice(start);
|
|
@@ -953,16 +906,16 @@ var require_scan = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
953
906
|
}
|
|
954
907
|
if (base && isGlob === true && lastIndex > 0) {
|
|
955
908
|
base = str.slice(0, lastIndex);
|
|
956
|
-
glob
|
|
909
|
+
glob = str.slice(lastIndex);
|
|
957
910
|
} else if (isGlob === true) {
|
|
958
911
|
base = "";
|
|
959
|
-
glob
|
|
912
|
+
glob = str;
|
|
960
913
|
} else base = str;
|
|
961
914
|
if (base && base !== "" && base !== "/" && base !== str) {
|
|
962
915
|
if (isPathSeparator(base.charCodeAt(base.length - 1))) base = base.slice(0, -1);
|
|
963
916
|
}
|
|
964
917
|
if (opts.unescape === true) {
|
|
965
|
-
if (glob
|
|
918
|
+
if (glob) glob = utils.removeBackslashes(glob);
|
|
966
919
|
if (base && backslashes === true) base = utils.removeBackslashes(base);
|
|
967
920
|
}
|
|
968
921
|
const state = {
|
|
@@ -970,7 +923,7 @@ var require_scan = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
970
923
|
input,
|
|
971
924
|
start,
|
|
972
925
|
base,
|
|
973
|
-
glob
|
|
926
|
+
glob,
|
|
974
927
|
isBrace,
|
|
975
928
|
isBracket,
|
|
976
929
|
isGlob,
|
|
@@ -987,9 +940,9 @@ var require_scan = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
987
940
|
if (opts.parts === true || opts.tokens === true) {
|
|
988
941
|
let prevIndex;
|
|
989
942
|
for (let idx = 0; idx < slashes.length; idx++) {
|
|
990
|
-
const n
|
|
943
|
+
const n = prevIndex ? prevIndex + 1 : start;
|
|
991
944
|
const i = slashes[idx];
|
|
992
|
-
const value = input.slice(n
|
|
945
|
+
const value = input.slice(n, i);
|
|
993
946
|
if (opts.tokens) {
|
|
994
947
|
if (idx === 0 && start !== 0) {
|
|
995
948
|
tokens[idx].isPrefix = true;
|
|
@@ -1020,16 +973,10 @@ var require_scan = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1020
973
|
|
|
1021
974
|
//#endregion
|
|
1022
975
|
//#region node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/parse.js
|
|
1023
|
-
var require_parse =
|
|
976
|
+
var require_parse = __commonJSMin(((exports, module) => {
|
|
1024
977
|
const constants = require_constants();
|
|
1025
978
|
const utils = require_utils();
|
|
1026
|
-
/**
|
|
1027
|
-
* Constants
|
|
1028
|
-
*/
|
|
1029
979
|
const { MAX_LENGTH, POSIX_REGEX_SOURCE, REGEX_NON_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_BACKREF, REPLACEMENTS } = constants;
|
|
1030
|
-
/**
|
|
1031
|
-
* Helpers
|
|
1032
|
-
*/
|
|
1033
980
|
const expandRange = (args, options) => {
|
|
1034
981
|
if (typeof options.expandRange === "function") return options.expandRange(...args, options);
|
|
1035
982
|
args.sort();
|
|
@@ -1041,18 +988,9 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1041
988
|
}
|
|
1042
989
|
return value;
|
|
1043
990
|
};
|
|
1044
|
-
/**
|
|
1045
|
-
* Create the message for a syntax error
|
|
1046
|
-
*/
|
|
1047
991
|
const syntaxError = (type, char) => {
|
|
1048
992
|
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
1049
993
|
};
|
|
1050
|
-
/**
|
|
1051
|
-
* Parse the given input string.
|
|
1052
|
-
* @param {String} input
|
|
1053
|
-
* @param {Object} options
|
|
1054
|
-
* @return {Object}
|
|
1055
|
-
*/
|
|
1056
994
|
const parse = (input, options) => {
|
|
1057
995
|
if (typeof input !== "string") throw new TypeError("Expected a string");
|
|
1058
996
|
input = REPLACEMENTS[input] || input;
|
|
@@ -1070,8 +1008,8 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1070
1008
|
const PLATFORM_CHARS = constants.globChars(opts.windows);
|
|
1071
1009
|
const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
|
|
1072
1010
|
const { DOT_LITERAL, PLUS_LITERAL, SLASH_LITERAL, ONE_CHAR, DOTS_SLASH, NO_DOT, NO_DOT_SLASH, NO_DOTS_SLASH, QMARK, QMARK_NO_DOT, STAR, START_ANCHOR } = PLATFORM_CHARS;
|
|
1073
|
-
const globstar = (opts
|
|
1074
|
-
return `(${capture}(?:(?!${START_ANCHOR}${opts
|
|
1011
|
+
const globstar = (opts) => {
|
|
1012
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
1075
1013
|
};
|
|
1076
1014
|
const nodot = opts.dot ? "" : NO_DOT;
|
|
1077
1015
|
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
@@ -1102,15 +1040,12 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1102
1040
|
const stack = [];
|
|
1103
1041
|
let prev = bos;
|
|
1104
1042
|
let value;
|
|
1105
|
-
/**
|
|
1106
|
-
* Tokenizing helpers
|
|
1107
|
-
*/
|
|
1108
1043
|
const eos = () => state.index === len - 1;
|
|
1109
|
-
const peek = state.peek = (n
|
|
1044
|
+
const peek = state.peek = (n = 1) => input[state.index + n];
|
|
1110
1045
|
const advance = state.advance = () => input[++state.index] || "";
|
|
1111
1046
|
const remaining = () => input.slice(state.index + 1);
|
|
1112
|
-
const consume = (value
|
|
1113
|
-
state.consumed += value
|
|
1047
|
+
const consume = (value = "", num = 0) => {
|
|
1048
|
+
state.consumed += value;
|
|
1114
1049
|
state.index += num;
|
|
1115
1050
|
};
|
|
1116
1051
|
const append = (token) => {
|
|
@@ -1137,13 +1072,6 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1137
1072
|
state[type]--;
|
|
1138
1073
|
stack.pop();
|
|
1139
1074
|
};
|
|
1140
|
-
/**
|
|
1141
|
-
* Push tokens onto the tokens array. This helper speeds up
|
|
1142
|
-
* tokenizing by 1) helping us avoid backtracking as much as possible,
|
|
1143
|
-
* and 2) helping us avoid creating extra tokens when consecutive
|
|
1144
|
-
* characters are plain text. This improves performance and simplifies
|
|
1145
|
-
* lookbehinds.
|
|
1146
|
-
*/
|
|
1147
1075
|
const push = (tok) => {
|
|
1148
1076
|
if (prev.type === "globstar") {
|
|
1149
1077
|
const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
|
|
@@ -1167,9 +1095,9 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1167
1095
|
tokens.push(tok);
|
|
1168
1096
|
prev = tok;
|
|
1169
1097
|
};
|
|
1170
|
-
const extglobOpen = (type, value
|
|
1098
|
+
const extglobOpen = (type, value) => {
|
|
1171
1099
|
const token = {
|
|
1172
|
-
...EXTGLOB_CHARS[value
|
|
1100
|
+
...EXTGLOB_CHARS[value],
|
|
1173
1101
|
conditions: 1,
|
|
1174
1102
|
inner: ""
|
|
1175
1103
|
};
|
|
@@ -1180,7 +1108,7 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1180
1108
|
increment("parens");
|
|
1181
1109
|
push({
|
|
1182
1110
|
type,
|
|
1183
|
-
value
|
|
1111
|
+
value,
|
|
1184
1112
|
output: state.output ? "" : ONE_CHAR
|
|
1185
1113
|
});
|
|
1186
1114
|
push({
|
|
@@ -1212,9 +1140,6 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1212
1140
|
});
|
|
1213
1141
|
decrement("parens");
|
|
1214
1142
|
};
|
|
1215
|
-
/**
|
|
1216
|
-
* Fast paths
|
|
1217
|
-
*/
|
|
1218
1143
|
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
1219
1144
|
let backslashes = false;
|
|
1220
1145
|
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
|
@@ -1245,15 +1170,9 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1245
1170
|
state.output = utils.wrapOutput(output, state, options);
|
|
1246
1171
|
return state;
|
|
1247
1172
|
}
|
|
1248
|
-
/**
|
|
1249
|
-
* Tokenize input until we reach end-of-string
|
|
1250
|
-
*/
|
|
1251
1173
|
while (!eos()) {
|
|
1252
1174
|
value = advance();
|
|
1253
1175
|
if (value === "\0") continue;
|
|
1254
|
-
/**
|
|
1255
|
-
* Escaped characters
|
|
1256
|
-
*/
|
|
1257
1176
|
if (value === "\\") {
|
|
1258
1177
|
const next = peek();
|
|
1259
1178
|
if (next === "/" && opts.bash !== true) continue;
|
|
@@ -1283,10 +1202,6 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1283
1202
|
continue;
|
|
1284
1203
|
}
|
|
1285
1204
|
}
|
|
1286
|
-
/**
|
|
1287
|
-
* If we're inside a regex character class, continue
|
|
1288
|
-
* until we reach the closing bracket.
|
|
1289
|
-
*/
|
|
1290
1205
|
if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
|
|
1291
1206
|
if (opts.posix !== false && value === ":") {
|
|
1292
1207
|
const inner = prev.value.slice(1);
|
|
@@ -1295,9 +1210,9 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1295
1210
|
if (inner.includes(":")) {
|
|
1296
1211
|
const idx = prev.value.lastIndexOf("[");
|
|
1297
1212
|
const pre = prev.value.slice(0, idx);
|
|
1298
|
-
const posix
|
|
1299
|
-
if (posix
|
|
1300
|
-
prev.value = pre + posix
|
|
1213
|
+
const posix = POSIX_REGEX_SOURCE[prev.value.slice(idx + 2)];
|
|
1214
|
+
if (posix) {
|
|
1215
|
+
prev.value = pre + posix;
|
|
1301
1216
|
state.backtrack = true;
|
|
1302
1217
|
advance();
|
|
1303
1218
|
if (!bos.output && tokens.indexOf(prev) === 1) bos.output = ONE_CHAR;
|
|
@@ -1313,19 +1228,12 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1313
1228
|
append({ value });
|
|
1314
1229
|
continue;
|
|
1315
1230
|
}
|
|
1316
|
-
/**
|
|
1317
|
-
* If we're inside a quoted string, continue
|
|
1318
|
-
* until we reach the closing double quote.
|
|
1319
|
-
*/
|
|
1320
1231
|
if (state.quotes === 1 && value !== "\"") {
|
|
1321
1232
|
value = utils.escapeRegex(value);
|
|
1322
1233
|
prev.value += value;
|
|
1323
1234
|
append({ value });
|
|
1324
1235
|
continue;
|
|
1325
1236
|
}
|
|
1326
|
-
/**
|
|
1327
|
-
* Double quotes
|
|
1328
|
-
*/
|
|
1329
1237
|
if (value === "\"") {
|
|
1330
1238
|
state.quotes = state.quotes === 1 ? 0 : 1;
|
|
1331
1239
|
if (opts.keepQuotes === true) push({
|
|
@@ -1334,9 +1242,6 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1334
1242
|
});
|
|
1335
1243
|
continue;
|
|
1336
1244
|
}
|
|
1337
|
-
/**
|
|
1338
|
-
* Parentheses
|
|
1339
|
-
*/
|
|
1340
1245
|
if (value === "(") {
|
|
1341
1246
|
increment("parens");
|
|
1342
1247
|
push({
|
|
@@ -1360,9 +1265,6 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1360
1265
|
decrement("parens");
|
|
1361
1266
|
continue;
|
|
1362
1267
|
}
|
|
1363
|
-
/**
|
|
1364
|
-
* Square brackets
|
|
1365
|
-
*/
|
|
1366
1268
|
if (value === "[") {
|
|
1367
1269
|
if (opts.nobracket === true || !remaining().includes("]")) {
|
|
1368
1270
|
if (opts.nobracket !== true && opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
|
|
@@ -1409,9 +1311,6 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1409
1311
|
state.output += prev.value;
|
|
1410
1312
|
continue;
|
|
1411
1313
|
}
|
|
1412
|
-
/**
|
|
1413
|
-
* Braces
|
|
1414
|
-
*/
|
|
1415
1314
|
if (value === "{" && opts.nobrace !== true) {
|
|
1416
1315
|
increment("braces");
|
|
1417
1316
|
const open = {
|
|
@@ -1464,9 +1363,6 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1464
1363
|
braces.pop();
|
|
1465
1364
|
continue;
|
|
1466
1365
|
}
|
|
1467
|
-
/**
|
|
1468
|
-
* Pipes
|
|
1469
|
-
*/
|
|
1470
1366
|
if (value === "|") {
|
|
1471
1367
|
if (extglobs.length > 0) extglobs[extglobs.length - 1].conditions++;
|
|
1472
1368
|
push({
|
|
@@ -1475,9 +1371,6 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1475
1371
|
});
|
|
1476
1372
|
continue;
|
|
1477
1373
|
}
|
|
1478
|
-
/**
|
|
1479
|
-
* Commas
|
|
1480
|
-
*/
|
|
1481
1374
|
if (value === ",") {
|
|
1482
1375
|
let output = value;
|
|
1483
1376
|
const brace = braces[braces.length - 1];
|
|
@@ -1492,9 +1385,6 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1492
1385
|
});
|
|
1493
1386
|
continue;
|
|
1494
1387
|
}
|
|
1495
|
-
/**
|
|
1496
|
-
* Slashes
|
|
1497
|
-
*/
|
|
1498
1388
|
if (value === "/") {
|
|
1499
1389
|
if (prev.type === "dot" && state.index === state.start + 1) {
|
|
1500
1390
|
state.start = state.index + 1;
|
|
@@ -1511,9 +1401,6 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1511
1401
|
});
|
|
1512
1402
|
continue;
|
|
1513
1403
|
}
|
|
1514
|
-
/**
|
|
1515
|
-
* Dots
|
|
1516
|
-
*/
|
|
1517
1404
|
if (value === ".") {
|
|
1518
1405
|
if (state.braces > 0 && prev.type === "dot") {
|
|
1519
1406
|
if (prev.value === ".") prev.output = DOT_LITERAL;
|
|
@@ -1539,9 +1426,6 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1539
1426
|
});
|
|
1540
1427
|
continue;
|
|
1541
1428
|
}
|
|
1542
|
-
/**
|
|
1543
|
-
* Question marks
|
|
1544
|
-
*/
|
|
1545
1429
|
if (value === "?") {
|
|
1546
1430
|
if (!(prev && prev.value === "(") && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1547
1431
|
extglobOpen("qmark", value);
|
|
@@ -1573,9 +1457,6 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1573
1457
|
});
|
|
1574
1458
|
continue;
|
|
1575
1459
|
}
|
|
1576
|
-
/**
|
|
1577
|
-
* Exclamation
|
|
1578
|
-
*/
|
|
1579
1460
|
if (value === "!") {
|
|
1580
1461
|
if (opts.noextglob !== true && peek() === "(") {
|
|
1581
1462
|
if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
|
|
@@ -1588,9 +1469,6 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1588
1469
|
continue;
|
|
1589
1470
|
}
|
|
1590
1471
|
}
|
|
1591
|
-
/**
|
|
1592
|
-
* Plus
|
|
1593
|
-
*/
|
|
1594
1472
|
if (value === "+") {
|
|
1595
1473
|
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1596
1474
|
extglobOpen("plus", value);
|
|
@@ -1617,9 +1495,6 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1617
1495
|
});
|
|
1618
1496
|
continue;
|
|
1619
1497
|
}
|
|
1620
|
-
/**
|
|
1621
|
-
* Plain text
|
|
1622
|
-
*/
|
|
1623
1498
|
if (value === "@") {
|
|
1624
1499
|
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1625
1500
|
push({
|
|
@@ -1636,9 +1511,6 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1636
1511
|
});
|
|
1637
1512
|
continue;
|
|
1638
1513
|
}
|
|
1639
|
-
/**
|
|
1640
|
-
* Plain text
|
|
1641
|
-
*/
|
|
1642
1514
|
if (value !== "*") {
|
|
1643
1515
|
if (value === "$" || value === "^") value = `\\${value}`;
|
|
1644
1516
|
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
@@ -1652,9 +1524,6 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1652
1524
|
});
|
|
1653
1525
|
continue;
|
|
1654
1526
|
}
|
|
1655
|
-
/**
|
|
1656
|
-
* Stars
|
|
1657
|
-
*/
|
|
1658
1527
|
if (prev && (prev.type === "globstar" || prev.star === true)) {
|
|
1659
1528
|
prev.type = "star";
|
|
1660
1529
|
prev.star = true;
|
|
@@ -1826,11 +1695,6 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1826
1695
|
}
|
|
1827
1696
|
return state;
|
|
1828
1697
|
};
|
|
1829
|
-
/**
|
|
1830
|
-
* Fast paths for creating regular expressions for common glob patterns.
|
|
1831
|
-
* This can significantly speed up processing and has very little downside
|
|
1832
|
-
* impact when none of the fast paths match.
|
|
1833
|
-
*/
|
|
1834
1698
|
parse.fastpaths = (input, options) => {
|
|
1835
1699
|
const opts = { ...options };
|
|
1836
1700
|
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
@@ -1847,9 +1711,9 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1847
1711
|
};
|
|
1848
1712
|
let star = opts.bash === true ? ".*?" : STAR;
|
|
1849
1713
|
if (opts.capture) star = `(${star})`;
|
|
1850
|
-
const globstar = (opts
|
|
1851
|
-
if (opts
|
|
1852
|
-
return `(${capture}(?:(?!${START_ANCHOR}${opts
|
|
1714
|
+
const globstar = (opts) => {
|
|
1715
|
+
if (opts.noglobstar === true) return star;
|
|
1716
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
1853
1717
|
};
|
|
1854
1718
|
const create = (str) => {
|
|
1855
1719
|
switch (str) {
|
|
@@ -1864,9 +1728,9 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1864
1728
|
default: {
|
|
1865
1729
|
const match = /^(.*?)\.(\w+)$/.exec(str);
|
|
1866
1730
|
if (!match) return;
|
|
1867
|
-
const source
|
|
1868
|
-
if (!source
|
|
1869
|
-
return source
|
|
1731
|
+
const source = create(match[1]);
|
|
1732
|
+
if (!source) return;
|
|
1733
|
+
return source + DOT_LITERAL + match[2];
|
|
1870
1734
|
}
|
|
1871
1735
|
}
|
|
1872
1736
|
};
|
|
@@ -1879,50 +1743,29 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1879
1743
|
|
|
1880
1744
|
//#endregion
|
|
1881
1745
|
//#region node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/picomatch.js
|
|
1882
|
-
var require_picomatch$1 =
|
|
1746
|
+
var require_picomatch$1 = __commonJSMin(((exports, module) => {
|
|
1883
1747
|
const scan = require_scan();
|
|
1884
1748
|
const parse = require_parse();
|
|
1885
1749
|
const utils = require_utils();
|
|
1886
1750
|
const constants = require_constants();
|
|
1887
1751
|
const isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
* and returns true if the string is a match. The returned matcher
|
|
1892
|
-
* function also takes a boolean as the second argument that, when true,
|
|
1893
|
-
* returns an object with additional information.
|
|
1894
|
-
*
|
|
1895
|
-
* ```js
|
|
1896
|
-
* const picomatch = require('picomatch');
|
|
1897
|
-
* // picomatch(glob[, options]);
|
|
1898
|
-
*
|
|
1899
|
-
* const isMatch = picomatch('*.!(*a)');
|
|
1900
|
-
* console.log(isMatch('a.a')); //=> false
|
|
1901
|
-
* console.log(isMatch('a.b')); //=> true
|
|
1902
|
-
* ```
|
|
1903
|
-
* @name picomatch
|
|
1904
|
-
* @param {String|Array} `globs` One or more glob patterns.
|
|
1905
|
-
* @param {Object=} `options`
|
|
1906
|
-
* @return {Function=} Returns a matcher function.
|
|
1907
|
-
* @api public
|
|
1908
|
-
*/
|
|
1909
|
-
const picomatch = (glob$2, options, returnState = false) => {
|
|
1910
|
-
if (Array.isArray(glob$2)) {
|
|
1911
|
-
const fns = glob$2.map((input) => picomatch(input, options, returnState));
|
|
1752
|
+
const picomatch = (glob, options, returnState = false) => {
|
|
1753
|
+
if (Array.isArray(glob)) {
|
|
1754
|
+
const fns = glob.map((input) => picomatch(input, options, returnState));
|
|
1912
1755
|
const arrayMatcher = (str) => {
|
|
1913
1756
|
for (const isMatch of fns) {
|
|
1914
|
-
const state
|
|
1915
|
-
if (state
|
|
1757
|
+
const state = isMatch(str);
|
|
1758
|
+
if (state) return state;
|
|
1916
1759
|
}
|
|
1917
1760
|
return false;
|
|
1918
1761
|
};
|
|
1919
1762
|
return arrayMatcher;
|
|
1920
1763
|
}
|
|
1921
|
-
const isState = isObject(glob
|
|
1922
|
-
if (glob
|
|
1764
|
+
const isState = isObject(glob) && glob.tokens && glob.input;
|
|
1765
|
+
if (glob === "" || typeof glob !== "string" && !isState) throw new TypeError("Expected pattern to be a non-empty string");
|
|
1923
1766
|
const opts = options || {};
|
|
1924
|
-
const posix
|
|
1925
|
-
const regex = isState ? picomatch.compileRe(glob
|
|
1767
|
+
const posix = opts.windows;
|
|
1768
|
+
const regex = isState ? picomatch.compileRe(glob, options) : picomatch.makeRe(glob, options, false, true);
|
|
1926
1769
|
const state = regex.state;
|
|
1927
1770
|
delete regex.state;
|
|
1928
1771
|
let isIgnored = () => false;
|
|
@@ -1937,14 +1780,14 @@ var require_picomatch$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1937
1780
|
}
|
|
1938
1781
|
const matcher = (input, returnObject = false) => {
|
|
1939
1782
|
const { isMatch, match, output } = picomatch.test(input, regex, options, {
|
|
1940
|
-
glob
|
|
1941
|
-
posix
|
|
1783
|
+
glob,
|
|
1784
|
+
posix
|
|
1942
1785
|
});
|
|
1943
1786
|
const result = {
|
|
1944
|
-
glob
|
|
1787
|
+
glob,
|
|
1945
1788
|
state,
|
|
1946
1789
|
regex,
|
|
1947
|
-
posix
|
|
1790
|
+
posix,
|
|
1948
1791
|
input,
|
|
1949
1792
|
output,
|
|
1950
1793
|
match,
|
|
@@ -1966,37 +1809,21 @@ var require_picomatch$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1966
1809
|
if (returnState) matcher.state = state;
|
|
1967
1810
|
return matcher;
|
|
1968
1811
|
};
|
|
1969
|
-
|
|
1970
|
-
* Test `input` with the given `regex`. This is used by the main
|
|
1971
|
-
* `picomatch()` function to test the input string.
|
|
1972
|
-
*
|
|
1973
|
-
* ```js
|
|
1974
|
-
* const picomatch = require('picomatch');
|
|
1975
|
-
* // picomatch.test(input, regex[, options]);
|
|
1976
|
-
*
|
|
1977
|
-
* console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
|
|
1978
|
-
* // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
|
|
1979
|
-
* ```
|
|
1980
|
-
* @param {String} `input` String to test.
|
|
1981
|
-
* @param {RegExp} `regex`
|
|
1982
|
-
* @return {Object} Returns an object with matching info.
|
|
1983
|
-
* @api public
|
|
1984
|
-
*/
|
|
1985
|
-
picomatch.test = (input, regex, options, { glob: glob$2, posix: posix$1 } = {}) => {
|
|
1812
|
+
picomatch.test = (input, regex, options, { glob, posix } = {}) => {
|
|
1986
1813
|
if (typeof input !== "string") throw new TypeError("Expected input to be a string");
|
|
1987
1814
|
if (input === "") return {
|
|
1988
1815
|
isMatch: false,
|
|
1989
1816
|
output: ""
|
|
1990
1817
|
};
|
|
1991
1818
|
const opts = options || {};
|
|
1992
|
-
const format = opts.format || (posix
|
|
1993
|
-
let match = input === glob
|
|
1819
|
+
const format = opts.format || (posix ? utils.toPosixSlashes : null);
|
|
1820
|
+
let match = input === glob;
|
|
1994
1821
|
let output = match && format ? format(input) : input;
|
|
1995
1822
|
if (match === false) {
|
|
1996
1823
|
output = format ? format(input) : input;
|
|
1997
|
-
match = output === glob
|
|
1824
|
+
match = output === glob;
|
|
1998
1825
|
}
|
|
1999
|
-
if (match === false || opts.capture === true) if (opts.matchBase === true || opts.basename === true) match = picomatch.matchBase(input, regex, options, posix
|
|
1826
|
+
if (match === false || opts.capture === true) if (opts.matchBase === true || opts.basename === true) match = picomatch.matchBase(input, regex, options, posix);
|
|
2000
1827
|
else match = regex.exec(output);
|
|
2001
1828
|
return {
|
|
2002
1829
|
isMatch: Boolean(match),
|
|
@@ -2004,52 +1831,10 @@ var require_picomatch$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2004
1831
|
output
|
|
2005
1832
|
};
|
|
2006
1833
|
};
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
*
|
|
2010
|
-
* ```js
|
|
2011
|
-
* const picomatch = require('picomatch');
|
|
2012
|
-
* // picomatch.matchBase(input, glob[, options]);
|
|
2013
|
-
* console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
|
|
2014
|
-
* ```
|
|
2015
|
-
* @param {String} `input` String to test.
|
|
2016
|
-
* @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
|
|
2017
|
-
* @return {Boolean}
|
|
2018
|
-
* @api public
|
|
2019
|
-
*/
|
|
2020
|
-
picomatch.matchBase = (input, glob$2, options) => {
|
|
2021
|
-
return (glob$2 instanceof RegExp ? glob$2 : picomatch.makeRe(glob$2, options)).test(utils.basename(input));
|
|
1834
|
+
picomatch.matchBase = (input, glob, options) => {
|
|
1835
|
+
return (glob instanceof RegExp ? glob : picomatch.makeRe(glob, options)).test(utils.basename(input));
|
|
2022
1836
|
};
|
|
2023
|
-
/**
|
|
2024
|
-
* Returns true if **any** of the given glob `patterns` match the specified `string`.
|
|
2025
|
-
*
|
|
2026
|
-
* ```js
|
|
2027
|
-
* const picomatch = require('picomatch');
|
|
2028
|
-
* // picomatch.isMatch(string, patterns[, options]);
|
|
2029
|
-
*
|
|
2030
|
-
* console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
|
|
2031
|
-
* console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
|
|
2032
|
-
* ```
|
|
2033
|
-
* @param {String|Array} str The string to test.
|
|
2034
|
-
* @param {String|Array} patterns One or more glob patterns to use for matching.
|
|
2035
|
-
* @param {Object} [options] See available [options](#options).
|
|
2036
|
-
* @return {Boolean} Returns true if any patterns match `str`
|
|
2037
|
-
* @api public
|
|
2038
|
-
*/
|
|
2039
1837
|
picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
|
|
2040
|
-
/**
|
|
2041
|
-
* Parse a glob pattern to create the source string for a regular
|
|
2042
|
-
* expression.
|
|
2043
|
-
*
|
|
2044
|
-
* ```js
|
|
2045
|
-
* const picomatch = require('picomatch');
|
|
2046
|
-
* const result = picomatch.parse(pattern[, options]);
|
|
2047
|
-
* ```
|
|
2048
|
-
* @param {String} `pattern`
|
|
2049
|
-
* @param {Object} `options`
|
|
2050
|
-
* @return {Object} Returns an object with useful properties and output to be used as a regex source string.
|
|
2051
|
-
* @api public
|
|
2052
|
-
*/
|
|
2053
1838
|
picomatch.parse = (pattern, options) => {
|
|
2054
1839
|
if (Array.isArray(pattern)) return pattern.map((p) => picomatch.parse(p, options));
|
|
2055
1840
|
return parse(pattern, {
|
|
@@ -2057,44 +1842,7 @@ var require_picomatch$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2057
1842
|
fastpaths: false
|
|
2058
1843
|
});
|
|
2059
1844
|
};
|
|
2060
|
-
/**
|
|
2061
|
-
* Scan a glob pattern to separate the pattern into segments.
|
|
2062
|
-
*
|
|
2063
|
-
* ```js
|
|
2064
|
-
* const picomatch = require('picomatch');
|
|
2065
|
-
* // picomatch.scan(input[, options]);
|
|
2066
|
-
*
|
|
2067
|
-
* const result = picomatch.scan('!./foo/*.js');
|
|
2068
|
-
* console.log(result);
|
|
2069
|
-
* { prefix: '!./',
|
|
2070
|
-
* input: '!./foo/*.js',
|
|
2071
|
-
* start: 3,
|
|
2072
|
-
* base: 'foo',
|
|
2073
|
-
* glob: '*.js',
|
|
2074
|
-
* isBrace: false,
|
|
2075
|
-
* isBracket: false,
|
|
2076
|
-
* isGlob: true,
|
|
2077
|
-
* isExtglob: false,
|
|
2078
|
-
* isGlobstar: false,
|
|
2079
|
-
* negated: true }
|
|
2080
|
-
* ```
|
|
2081
|
-
* @param {String} `input` Glob pattern to scan.
|
|
2082
|
-
* @param {Object} `options`
|
|
2083
|
-
* @return {Object} Returns an object with
|
|
2084
|
-
* @api public
|
|
2085
|
-
*/
|
|
2086
1845
|
picomatch.scan = (input, options) => scan(input, options);
|
|
2087
|
-
/**
|
|
2088
|
-
* Compile a regular expression from the `state` object returned by the
|
|
2089
|
-
* [parse()](#parse) method.
|
|
2090
|
-
*
|
|
2091
|
-
* @param {Object} `state`
|
|
2092
|
-
* @param {Object} `options`
|
|
2093
|
-
* @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
|
|
2094
|
-
* @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
|
|
2095
|
-
* @return {RegExp}
|
|
2096
|
-
* @api public
|
|
2097
|
-
*/
|
|
2098
1846
|
picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
2099
1847
|
if (returnOutput === true) return state.output;
|
|
2100
1848
|
const opts = options || {};
|
|
@@ -2106,24 +1854,6 @@ var require_picomatch$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2106
1854
|
if (returnState === true) regex.state = state;
|
|
2107
1855
|
return regex;
|
|
2108
1856
|
};
|
|
2109
|
-
/**
|
|
2110
|
-
* Create a regular expression from a parsed glob pattern.
|
|
2111
|
-
*
|
|
2112
|
-
* ```js
|
|
2113
|
-
* const picomatch = require('picomatch');
|
|
2114
|
-
* const state = picomatch.parse('*.js');
|
|
2115
|
-
* // picomatch.compileRe(state[, options]);
|
|
2116
|
-
*
|
|
2117
|
-
* console.log(picomatch.compileRe(state));
|
|
2118
|
-
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
2119
|
-
* ```
|
|
2120
|
-
* @param {String} `state` The object returned from the `.parse` method.
|
|
2121
|
-
* @param {Object} `options`
|
|
2122
|
-
* @param {Boolean} `returnOutput` Implementors may use this argument to return the compiled output, instead of a regular expression. This is not exposed on the options to prevent end-users from mutating the result.
|
|
2123
|
-
* @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
|
|
2124
|
-
* @return {RegExp} Returns a regex created from the given pattern.
|
|
2125
|
-
* @api public
|
|
2126
|
-
*/
|
|
2127
1857
|
picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
|
2128
1858
|
if (!input || typeof input !== "string") throw new TypeError("Expected a non-empty string");
|
|
2129
1859
|
let parsed = {
|
|
@@ -2134,53 +1864,30 @@ var require_picomatch$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2134
1864
|
if (!parsed.output) parsed = parse(input, options);
|
|
2135
1865
|
return picomatch.compileRe(parsed, options, returnOutput, returnState);
|
|
2136
1866
|
};
|
|
2137
|
-
/**
|
|
2138
|
-
* Create a regular expression from the given regex source string.
|
|
2139
|
-
*
|
|
2140
|
-
* ```js
|
|
2141
|
-
* const picomatch = require('picomatch');
|
|
2142
|
-
* // picomatch.toRegex(source[, options]);
|
|
2143
|
-
*
|
|
2144
|
-
* const { output } = picomatch.parse('*.js');
|
|
2145
|
-
* console.log(picomatch.toRegex(output));
|
|
2146
|
-
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
2147
|
-
* ```
|
|
2148
|
-
* @param {String} `source` Regular expression source string.
|
|
2149
|
-
* @param {Object} `options`
|
|
2150
|
-
* @return {RegExp}
|
|
2151
|
-
* @api public
|
|
2152
|
-
*/
|
|
2153
1867
|
picomatch.toRegex = (source, options) => {
|
|
2154
1868
|
try {
|
|
2155
1869
|
const opts = options || {};
|
|
2156
1870
|
return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
|
|
2157
|
-
} catch (err
|
|
2158
|
-
if (options && options.debug === true) throw err
|
|
1871
|
+
} catch (err) {
|
|
1872
|
+
if (options && options.debug === true) throw err;
|
|
2159
1873
|
return /$^/;
|
|
2160
1874
|
}
|
|
2161
1875
|
};
|
|
2162
|
-
/**
|
|
2163
|
-
* Picomatch constants.
|
|
2164
|
-
* @return {Object}
|
|
2165
|
-
*/
|
|
2166
1876
|
picomatch.constants = constants;
|
|
2167
|
-
/**
|
|
2168
|
-
* Expose "picomatch"
|
|
2169
|
-
*/
|
|
2170
1877
|
module.exports = picomatch;
|
|
2171
1878
|
}));
|
|
2172
1879
|
|
|
2173
1880
|
//#endregion
|
|
2174
1881
|
//#region node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.js
|
|
2175
|
-
var require_picomatch =
|
|
1882
|
+
var require_picomatch = __commonJSMin(((exports, module) => {
|
|
2176
1883
|
const pico = require_picomatch$1();
|
|
2177
1884
|
const utils = require_utils();
|
|
2178
|
-
function picomatch(glob
|
|
1885
|
+
function picomatch(glob, options, returnState = false) {
|
|
2179
1886
|
if (options && (options.windows === null || options.windows === void 0)) options = {
|
|
2180
1887
|
...options,
|
|
2181
1888
|
windows: utils.isWindows()
|
|
2182
1889
|
};
|
|
2183
|
-
return pico(glob
|
|
1890
|
+
return pico(glob, options, returnState);
|
|
2184
1891
|
}
|
|
2185
1892
|
Object.assign(picomatch, pico);
|
|
2186
1893
|
module.exports = picomatch;
|
|
@@ -2188,7 +1895,7 @@ var require_picomatch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2188
1895
|
|
|
2189
1896
|
//#endregion
|
|
2190
1897
|
//#region node_modules/.pnpm/tinyglobby@0.2.15/node_modules/tinyglobby/dist/index.mjs
|
|
2191
|
-
var import_picomatch =
|
|
1898
|
+
var import_picomatch = __toESM(require_picomatch(), 1);
|
|
2192
1899
|
const isReadonlyArray = Array.isArray;
|
|
2193
1900
|
const isWin = process.platform === "win32";
|
|
2194
1901
|
const ONLY_PARENT_DIRECTORIES = /^(\/?\.\.)+$/;
|
|
@@ -2226,7 +1933,6 @@ function getPartialMatcher(patterns, options = {}) {
|
|
|
2226
1933
|
return false;
|
|
2227
1934
|
};
|
|
2228
1935
|
}
|
|
2229
|
-
/* node:coverage ignore next 2 */
|
|
2230
1936
|
const WIN32_ROOT_DIR = /^[A-Z]:\/$/i;
|
|
2231
1937
|
const isRoot = isWin ? (p) => WIN32_ROOT_DIR.test(p) : (p) => p === "/";
|
|
2232
1938
|
function buildFormat(cwd, root, absolute) {
|
|
@@ -2258,54 +1964,31 @@ function buildRelative(cwd, root) {
|
|
|
2258
1964
|
};
|
|
2259
1965
|
}
|
|
2260
1966
|
const splitPatternOptions = { parts: true };
|
|
2261
|
-
function splitPattern(path$1
|
|
1967
|
+
function splitPattern(path$1) {
|
|
2262
1968
|
var _result$parts;
|
|
2263
|
-
const result = import_picomatch.default.scan(path$1
|
|
2264
|
-
return ((_result$parts = result.parts) === null || _result$parts === void 0 ? void 0 : _result$parts.length) ? result.parts : [path$1
|
|
1969
|
+
const result = import_picomatch.default.scan(path$1, splitPatternOptions);
|
|
1970
|
+
return ((_result$parts = result.parts) === null || _result$parts === void 0 ? void 0 : _result$parts.length) ? result.parts : [path$1];
|
|
2265
1971
|
}
|
|
2266
1972
|
const ESCAPED_WIN32_BACKSLASHES = /\\(?![()[\]{}!+@])/g;
|
|
2267
|
-
function convertPosixPathToPattern(path$1
|
|
2268
|
-
return escapePosixPath(path$1
|
|
1973
|
+
function convertPosixPathToPattern(path$1) {
|
|
1974
|
+
return escapePosixPath(path$1);
|
|
2269
1975
|
}
|
|
2270
|
-
function convertWin32PathToPattern(path$1
|
|
2271
|
-
return escapeWin32Path(path$1
|
|
1976
|
+
function convertWin32PathToPattern(path$1) {
|
|
1977
|
+
return escapeWin32Path(path$1).replace(ESCAPED_WIN32_BACKSLASHES, "/");
|
|
2272
1978
|
}
|
|
2273
|
-
/**
|
|
2274
|
-
* Converts a path to a pattern depending on the platform.
|
|
2275
|
-
* Identical to {@link escapePath} on POSIX systems.
|
|
2276
|
-
* @see {@link https://superchupu.dev/tinyglobby/documentation#convertPathToPattern}
|
|
2277
|
-
*/
|
|
2278
|
-
/* node:coverage ignore next 3 */
|
|
2279
1979
|
const convertPathToPattern = isWin ? convertWin32PathToPattern : convertPosixPathToPattern;
|
|
2280
1980
|
const POSIX_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g;
|
|
2281
1981
|
const WIN32_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g;
|
|
2282
|
-
const escapePosixPath = (path$1
|
|
2283
|
-
const escapeWin32Path = (path$1
|
|
2284
|
-
/**
|
|
2285
|
-
* Escapes a path's special characters depending on the platform.
|
|
2286
|
-
* @see {@link https://superchupu.dev/tinyglobby/documentation#escapePath}
|
|
2287
|
-
*/
|
|
2288
|
-
/* node:coverage ignore next */
|
|
1982
|
+
const escapePosixPath = (path$1) => path$1.replace(POSIX_UNESCAPED_GLOB_SYMBOLS, "\\$&");
|
|
1983
|
+
const escapeWin32Path = (path$1) => path$1.replace(WIN32_UNESCAPED_GLOB_SYMBOLS, "\\$&");
|
|
2289
1984
|
const escapePath = isWin ? escapeWin32Path : escapePosixPath;
|
|
2290
|
-
/**
|
|
2291
|
-
* Checks if a pattern has dynamic parts.
|
|
2292
|
-
*
|
|
2293
|
-
* Has a few minor differences with [`fast-glob`](https://github.com/mrmlnc/fast-glob) for better accuracy:
|
|
2294
|
-
*
|
|
2295
|
-
* - Doesn't necessarily return `false` on patterns that include `\`.
|
|
2296
|
-
* - Returns `true` if the pattern includes parentheses, regardless of them representing one single pattern or not.
|
|
2297
|
-
* - Returns `true` for unfinished glob extensions i.e. `(h`, `+(h`.
|
|
2298
|
-
* - Returns `true` for unfinished brace expansions as long as they include `,` or `..`.
|
|
2299
|
-
*
|
|
2300
|
-
* @see {@link https://superchupu.dev/tinyglobby/documentation#isDynamicPattern}
|
|
2301
|
-
*/
|
|
2302
1985
|
function isDynamicPattern(pattern, options) {
|
|
2303
1986
|
if ((options === null || options === void 0 ? void 0 : options.caseSensitiveMatch) === false) return true;
|
|
2304
1987
|
const scan = import_picomatch.default.scan(pattern);
|
|
2305
1988
|
return scan.isGlob || scan.negated;
|
|
2306
1989
|
}
|
|
2307
1990
|
function log(...tasks) {
|
|
2308
|
-
console.log(`[tinyglobby ${
|
|
1991
|
+
console.log(`[tinyglobby ${new Date().toLocaleTimeString("es")}]`, ...tasks);
|
|
2309
1992
|
}
|
|
2310
1993
|
const PARENT_DIRECTORY = /^(\/?\.\.)+/;
|
|
2311
1994
|
const ESCAPING_BACKSLASHES = /\\(?=[()[\]{}!*+?@|])/g;
|
|
@@ -2320,17 +2003,17 @@ function normalizePattern(pattern, expandDirectories, cwd, props, isIgnore) {
|
|
|
2320
2003
|
const parentDirectoryMatch = PARENT_DIRECTORY.exec(result);
|
|
2321
2004
|
const parts = splitPattern(result);
|
|
2322
2005
|
if (parentDirectoryMatch === null || parentDirectoryMatch === void 0 ? void 0 : parentDirectoryMatch[0]) {
|
|
2323
|
-
const n
|
|
2006
|
+
const n = (parentDirectoryMatch[0].length + 1) / 3;
|
|
2324
2007
|
let i = 0;
|
|
2325
2008
|
const cwdParts = escapedCwd.split("/");
|
|
2326
|
-
while (i < n
|
|
2327
|
-
result = result.slice(0, (n
|
|
2009
|
+
while (i < n && parts[i + n] === cwdParts[cwdParts.length + i - n]) {
|
|
2010
|
+
result = result.slice(0, (n - i - 1) * 3) + result.slice((n - i) * 3 + parts[i + n].length + 1) || ".";
|
|
2328
2011
|
i++;
|
|
2329
2012
|
}
|
|
2330
2013
|
const potentialRoot = posix.join(cwd, parentDirectoryMatch[0].slice(i * 3));
|
|
2331
2014
|
if (!potentialRoot.startsWith(".") && props.root.length > potentialRoot.length) {
|
|
2332
2015
|
props.root = potentialRoot;
|
|
2333
|
-
props.depthOffset = -n
|
|
2016
|
+
props.depthOffset = -n + i;
|
|
2334
2017
|
}
|
|
2335
2018
|
}
|
|
2336
2019
|
if (!isIgnore && props.depthOffset >= 0) {
|
|
@@ -2372,10 +2055,10 @@ function processPatterns({ patterns = ["**/*"], ignore = [], expandDirectories =
|
|
|
2372
2055
|
ignore: ignorePatterns
|
|
2373
2056
|
};
|
|
2374
2057
|
}
|
|
2375
|
-
function formatPaths(paths, relative
|
|
2058
|
+
function formatPaths(paths, relative) {
|
|
2376
2059
|
for (let i = paths.length - 1; i >= 0; i--) {
|
|
2377
|
-
const path$1
|
|
2378
|
-
paths[i] = relative
|
|
2060
|
+
const path$1 = paths[i];
|
|
2061
|
+
paths[i] = relative(path$1);
|
|
2379
2062
|
}
|
|
2380
2063
|
return paths;
|
|
2381
2064
|
}
|
|
@@ -2427,9 +2110,9 @@ function getCrawler(patterns, inputOptions = {}) {
|
|
|
2427
2110
|
const formatExclude = options.absolute ? format : buildFormat(cwd, props.root, true);
|
|
2428
2111
|
const fdirOptions = {
|
|
2429
2112
|
filters: [options.debug ? (p, isDirectory) => {
|
|
2430
|
-
const path$1
|
|
2431
|
-
const matches = matcher(path$1
|
|
2432
|
-
if (matches) log(`matched ${path$1
|
|
2113
|
+
const path$1 = format(p, isDirectory);
|
|
2114
|
+
const matches = matcher(path$1);
|
|
2115
|
+
if (matches) log(`matched ${path$1}`);
|
|
2433
2116
|
return matches;
|
|
2434
2117
|
} : (p, isDirectory) => matcher(format(p, isDirectory))],
|
|
2435
2118
|
exclude: options.debug ? (_, p) => {
|
|
@@ -2472,33 +2155,33 @@ function getCrawler(patterns, inputOptions = {}) {
|
|
|
2472
2155
|
props.root = props.root.replace(BACKSLASHES, "");
|
|
2473
2156
|
const root = props.root;
|
|
2474
2157
|
if (options.debug) log("internal properties:", props);
|
|
2475
|
-
const relative
|
|
2476
|
-
return [new Builder(fdirOptions).crawl(root), relative
|
|
2158
|
+
const relative = cwd !== root && !options.absolute && buildRelative(cwd, props.root);
|
|
2159
|
+
return [new Builder(fdirOptions).crawl(root), relative];
|
|
2477
2160
|
}
|
|
2478
2161
|
async function glob$1(patternsOrOptions, options) {
|
|
2479
2162
|
if (patternsOrOptions && (options === null || options === void 0 ? void 0 : options.patterns)) throw new Error("Cannot pass patterns as both an argument and an option");
|
|
2480
2163
|
const isModern = isReadonlyArray(patternsOrOptions) || typeof patternsOrOptions === "string";
|
|
2481
2164
|
const opts = isModern ? options : patternsOrOptions;
|
|
2482
|
-
const [crawler, relative
|
|
2483
|
-
if (!relative
|
|
2484
|
-
return formatPaths(await crawler.withPromise(), relative
|
|
2165
|
+
const [crawler, relative] = getCrawler(isModern ? patternsOrOptions : patternsOrOptions.patterns, opts);
|
|
2166
|
+
if (!relative) return crawler.withPromise();
|
|
2167
|
+
return formatPaths(await crawler.withPromise(), relative);
|
|
2485
2168
|
}
|
|
2486
2169
|
function globSync$1(patternsOrOptions, options) {
|
|
2487
2170
|
if (patternsOrOptions && (options === null || options === void 0 ? void 0 : options.patterns)) throw new Error("Cannot pass patterns as both an argument and an option");
|
|
2488
2171
|
const isModern = isReadonlyArray(patternsOrOptions) || typeof patternsOrOptions === "string";
|
|
2489
2172
|
const opts = isModern ? options : patternsOrOptions;
|
|
2490
|
-
const [crawler, relative
|
|
2491
|
-
if (!relative
|
|
2492
|
-
return formatPaths(crawler.sync(), relative
|
|
2173
|
+
const [crawler, relative] = getCrawler(isModern ? patternsOrOptions : patternsOrOptions.patterns, opts);
|
|
2174
|
+
if (!relative) return crawler.sync();
|
|
2175
|
+
return formatPaths(crawler.sync(), relative);
|
|
2493
2176
|
}
|
|
2494
2177
|
|
|
2495
2178
|
//#endregion
|
|
2496
2179
|
//#region src/fs/glob.ts
|
|
2497
2180
|
const normalizeArgs = (patternsOrOptions, maybeOptions) => {
|
|
2498
|
-
const patternsAsArgument =
|
|
2181
|
+
const patternsAsArgument = isString(patternsOrOptions) || isArray(patternsOrOptions);
|
|
2499
2182
|
return {
|
|
2500
2183
|
patterns: patternsAsArgument ? patternsOrOptions : patternsOrOptions.patterns,
|
|
2501
|
-
options: patternsAsArgument ? maybeOptions || {} :
|
|
2184
|
+
options: patternsAsArgument ? maybeOptions || {} : omit(patternsOrOptions, ["patterns"])
|
|
2502
2185
|
};
|
|
2503
2186
|
};
|
|
2504
2187
|
function glob(...args) {
|
|
@@ -2524,7 +2207,7 @@ const parseEncodingOptions = (options) => {
|
|
|
2524
2207
|
return encoding === "buffer" ? {} : { encoding };
|
|
2525
2208
|
};
|
|
2526
2209
|
const parseWriteJsonOptions = (options) => {
|
|
2527
|
-
if (
|
|
2210
|
+
if (isNumber(options)) return {
|
|
2528
2211
|
indent: options,
|
|
2529
2212
|
encoding: parseEncodingOptions()
|
|
2530
2213
|
};
|
|
@@ -2533,89 +2216,89 @@ const parseWriteJsonOptions = (options) => {
|
|
|
2533
2216
|
encoding: parseEncodingOptions(options)
|
|
2534
2217
|
};
|
|
2535
2218
|
};
|
|
2536
|
-
const appendFile$1 = async (path
|
|
2219
|
+
const appendFile$1 = async (path, data, options) => Result.gen(async function* () {
|
|
2537
2220
|
const newline = options?.newline ?? true;
|
|
2538
|
-
yield* await mkdir$1(dirname$1(pathLikeToPath(path
|
|
2221
|
+
yield* await mkdir$1(dirname$1(pathLikeToPath(path).toString()));
|
|
2539
2222
|
const fn = async () => {
|
|
2540
|
-
await promises.appendFile(path
|
|
2223
|
+
await promises.appendFile(path, newline ? `\n${data}` : data, parseEncodingOptions(options));
|
|
2541
2224
|
};
|
|
2542
|
-
return (await Result.
|
|
2225
|
+
return (await Result.try(fn, Error)).context(`Failed to append file: ${path}`);
|
|
2543
2226
|
});
|
|
2544
|
-
const appendFileSync$1 = (path
|
|
2227
|
+
const appendFileSync$1 = (path, data, options) => Result.gen(function* () {
|
|
2545
2228
|
const newline = options?.newline ?? true;
|
|
2546
|
-
yield* mkdirSync$1(dirname$1(pathLikeToPath(path
|
|
2229
|
+
yield* mkdirSync$1(dirname$1(pathLikeToPath(path).toString()));
|
|
2547
2230
|
const fn = () => {
|
|
2548
|
-
fs.appendFileSync(path
|
|
2231
|
+
fs.appendFileSync(path, newline ? `\n${data}` : data, parseEncodingOptions(options));
|
|
2549
2232
|
};
|
|
2550
|
-
return Result.
|
|
2233
|
+
return Result.try(fn, Error).context(`Failed to append file: ${path}`);
|
|
2551
2234
|
});
|
|
2552
2235
|
const cp$1 = async (source, destination, options) => {
|
|
2553
2236
|
const { recursive = true } = options || {};
|
|
2554
2237
|
const fn = async () => {
|
|
2555
2238
|
await promises.cp(source, destination, { recursive });
|
|
2556
2239
|
};
|
|
2557
|
-
return (await Result.
|
|
2240
|
+
return (await Result.try(fn, Error)).context(`Failed to copy path: ${source} to ${destination}`);
|
|
2558
2241
|
};
|
|
2559
2242
|
const cpSync$1 = (source, destination, options) => {
|
|
2560
2243
|
const { recursive = true } = options || {};
|
|
2561
2244
|
const fn = () => {
|
|
2562
2245
|
fs.cpSync(source, destination, { recursive });
|
|
2563
2246
|
};
|
|
2564
|
-
return Result.
|
|
2247
|
+
return Result.try(fn, Error).context(`Failed to copy path: ${source} to ${destination}`);
|
|
2565
2248
|
};
|
|
2566
|
-
const exists$1 = async (path
|
|
2249
|
+
const exists$1 = async (path) => {
|
|
2567
2250
|
const fn = async () => {
|
|
2568
|
-
await promises.access(path
|
|
2251
|
+
await promises.access(path);
|
|
2569
2252
|
return true;
|
|
2570
2253
|
};
|
|
2571
|
-
return (await Result.
|
|
2254
|
+
return (await Result.try(fn, Error)).context(`Failed to check exists for path: ${path}`);
|
|
2572
2255
|
};
|
|
2573
|
-
const existsSync$1 = (path
|
|
2256
|
+
const existsSync$1 = (path) => {
|
|
2574
2257
|
const fn = () => {
|
|
2575
|
-
fs.accessSync(path
|
|
2258
|
+
fs.accessSync(path);
|
|
2576
2259
|
return true;
|
|
2577
2260
|
};
|
|
2578
|
-
return Result.
|
|
2261
|
+
return Result.try(fn, Error).context(`Failed to check exists for path: ${path}`);
|
|
2579
2262
|
};
|
|
2580
|
-
const mkdir$1 = async (path
|
|
2263
|
+
const mkdir$1 = async (path, options) => {
|
|
2581
2264
|
const { recursive = true } = options || {};
|
|
2582
|
-
if ((await exists$1(path
|
|
2265
|
+
if ((await exists$1(path)).isOk()) return ok();
|
|
2583
2266
|
const fn = async () => {
|
|
2584
|
-
await promises.mkdir(path
|
|
2267
|
+
await promises.mkdir(path, { recursive });
|
|
2585
2268
|
};
|
|
2586
|
-
return (await Result.
|
|
2269
|
+
return (await Result.try(fn, Error)).context(`Failed to create directory: ${path}`);
|
|
2587
2270
|
};
|
|
2588
|
-
const mkdirSync$1 = (path
|
|
2271
|
+
const mkdirSync$1 = (path, options) => {
|
|
2589
2272
|
const { recursive = true } = options || {};
|
|
2590
|
-
if (existsSync$1(path
|
|
2273
|
+
if (existsSync$1(path).isOk()) return ok();
|
|
2591
2274
|
const fn = () => {
|
|
2592
|
-
fs.mkdirSync(path
|
|
2275
|
+
fs.mkdirSync(path, { recursive });
|
|
2593
2276
|
};
|
|
2594
|
-
return Result.
|
|
2277
|
+
return Result.try(fn, Error).context(`Failed to create directory: ${path}`);
|
|
2595
2278
|
};
|
|
2596
|
-
async function readFile$1(path
|
|
2597
|
-
return
|
|
2598
|
-
yield* await exists$1(path
|
|
2279
|
+
async function readFile$1(path, options) {
|
|
2280
|
+
return Result.gen(async function* () {
|
|
2281
|
+
yield* await exists$1(path);
|
|
2599
2282
|
const fn = async () => {
|
|
2600
|
-
return await promises.readFile(path
|
|
2283
|
+
return await promises.readFile(path, parseEncodingOptions(options));
|
|
2601
2284
|
};
|
|
2602
|
-
return (await Result.
|
|
2285
|
+
return (await Result.try(fn, Error)).context(`Failed to read file: ${path}`);
|
|
2603
2286
|
});
|
|
2604
2287
|
}
|
|
2605
|
-
function readFileSync$1(path
|
|
2606
|
-
return
|
|
2607
|
-
yield* existsSync$1(path
|
|
2288
|
+
function readFileSync$1(path, options) {
|
|
2289
|
+
return Result.gen(function* () {
|
|
2290
|
+
yield* existsSync$1(path);
|
|
2608
2291
|
const fn = () => {
|
|
2609
|
-
return fs.readFileSync(path
|
|
2292
|
+
return fs.readFileSync(path, parseEncodingOptions(options));
|
|
2610
2293
|
};
|
|
2611
|
-
return Result.
|
|
2294
|
+
return Result.try(fn, Error).context(`Failed to read file: ${path}`);
|
|
2612
2295
|
});
|
|
2613
2296
|
}
|
|
2614
|
-
const readFileByLine$1 = (path
|
|
2615
|
-
yield* await exists$1(path
|
|
2297
|
+
const readFileByLine$1 = (path, options) => Result.gen(async function* () {
|
|
2298
|
+
yield* await exists$1(path);
|
|
2616
2299
|
const { createInterface } = await import("node:readline");
|
|
2617
2300
|
const fn = () => {
|
|
2618
|
-
const stream = fs.createReadStream(path
|
|
2301
|
+
const stream = fs.createReadStream(path, {
|
|
2619
2302
|
...parseEncodingOptions(options),
|
|
2620
2303
|
autoClose: true
|
|
2621
2304
|
});
|
|
@@ -2627,67 +2310,67 @@ const readFileByLine$1 = (path$2, options) => safeTry(async function* () {
|
|
|
2627
2310
|
crlfDelay: Infinity
|
|
2628
2311
|
});
|
|
2629
2312
|
};
|
|
2630
|
-
return Result.
|
|
2313
|
+
return Result.try(fn, Error).context(`Failed to read file: ${path}`);
|
|
2631
2314
|
});
|
|
2632
|
-
const readJson$1 = async (path
|
|
2633
|
-
const content = yield* await readFile$1(path
|
|
2634
|
-
if (!content) return err(
|
|
2635
|
-
return safeParse(content).context(`Failed to parse JSON file: ${path
|
|
2315
|
+
const readJson$1 = async (path, options) => Result.gen(async function* () {
|
|
2316
|
+
const content = yield* await readFile$1(path, options);
|
|
2317
|
+
if (!content) return err(new Error(`JSON file is empty: ${path}`));
|
|
2318
|
+
return safeParse(content).context(`Failed to parse JSON file: ${path}`);
|
|
2636
2319
|
});
|
|
2637
|
-
const readJsonSync$1 = (path
|
|
2638
|
-
const content = yield* readFileSync$1(path
|
|
2639
|
-
if (!content) return err(
|
|
2640
|
-
return safeParse(content).context(`Failed to parse JSON file: ${path
|
|
2320
|
+
const readJsonSync$1 = (path, options) => Result.gen(function* () {
|
|
2321
|
+
const content = yield* readFileSync$1(path, options);
|
|
2322
|
+
if (!content) return err(new Error(`JSON file is empty: ${path}`));
|
|
2323
|
+
return safeParse(content).context(`Failed to parse JSON file: ${path}`);
|
|
2641
2324
|
});
|
|
2642
|
-
const rm$1 = async (path
|
|
2325
|
+
const rm$1 = async (path, options) => {
|
|
2643
2326
|
const { force = true, recursive = true } = options || {};
|
|
2644
2327
|
const fn = async () => {
|
|
2645
|
-
await promises.rm(path
|
|
2328
|
+
await promises.rm(path, {
|
|
2646
2329
|
force,
|
|
2647
2330
|
recursive
|
|
2648
2331
|
});
|
|
2649
2332
|
};
|
|
2650
|
-
return (await Result.
|
|
2333
|
+
return (await Result.try(fn, Error)).context(`Failed to remove path: ${path}`);
|
|
2651
2334
|
};
|
|
2652
|
-
const rmSync$1 = (path
|
|
2335
|
+
const rmSync$1 = (path, options) => {
|
|
2653
2336
|
const { force = true, recursive = true } = options || {};
|
|
2654
2337
|
const fn = () => {
|
|
2655
|
-
fs.rmSync(path
|
|
2338
|
+
fs.rmSync(path, {
|
|
2656
2339
|
force,
|
|
2657
2340
|
recursive
|
|
2658
2341
|
});
|
|
2659
2342
|
};
|
|
2660
|
-
return Result.
|
|
2343
|
+
return Result.try(fn, Error).context(`Failed to remove path: ${path}`);
|
|
2661
2344
|
};
|
|
2662
|
-
const writeFile = async (path
|
|
2663
|
-
yield* await mkdir$1(dirname$1(pathLikeToPath(path
|
|
2345
|
+
const writeFile = async (path, data, options) => Result.gen(async function* () {
|
|
2346
|
+
yield* await mkdir$1(dirname$1(pathLikeToPath(path).toString()));
|
|
2664
2347
|
const fn = async () => {
|
|
2665
|
-
await promises.writeFile(path
|
|
2348
|
+
await promises.writeFile(path, data, parseEncodingOptions(options));
|
|
2666
2349
|
};
|
|
2667
|
-
return (await Result.
|
|
2350
|
+
return (await Result.try(fn, Error)).context(`Failed to write file: ${path}`);
|
|
2668
2351
|
});
|
|
2669
|
-
const writeFileSync = (path
|
|
2352
|
+
const writeFileSync = (path, data, options) => {
|
|
2670
2353
|
const fn = () => {
|
|
2671
|
-
fs.writeFileSync(path
|
|
2354
|
+
fs.writeFileSync(path, data, parseEncodingOptions(options));
|
|
2672
2355
|
};
|
|
2673
|
-
return Result.
|
|
2356
|
+
return Result.try(fn, Error).context(`Failed to write file: ${path}`);
|
|
2674
2357
|
};
|
|
2675
|
-
const writeJson = async (path
|
|
2358
|
+
const writeJson = async (path, data, indentOrOptions) => {
|
|
2676
2359
|
const { indent, encoding } = parseWriteJsonOptions(indentOrOptions);
|
|
2677
|
-
return writeFile(path
|
|
2360
|
+
return writeFile(path, stringify(data, null, indent) ?? "", encoding);
|
|
2678
2361
|
};
|
|
2679
|
-
const writeJsonSync = (path
|
|
2362
|
+
const writeJsonSync = (path, data, indentOrOptions) => {
|
|
2680
2363
|
const { indent, encoding } = parseWriteJsonOptions(indentOrOptions);
|
|
2681
|
-
return writeFileSync(path
|
|
2364
|
+
return writeFileSync(path, stringify(data, null, indent) ?? "", encoding);
|
|
2682
2365
|
};
|
|
2683
2366
|
|
|
2684
2367
|
//#endregion
|
|
2685
2368
|
//#region src/fs/unsafe.ts
|
|
2686
|
-
const appendFile = async (path
|
|
2687
|
-
await appendFile$1(path
|
|
2369
|
+
const appendFile = async (path, data, options) => {
|
|
2370
|
+
await appendFile$1(path, data, options);
|
|
2688
2371
|
};
|
|
2689
|
-
const appendFileSync = (path
|
|
2690
|
-
appendFileSync$1(path
|
|
2372
|
+
const appendFileSync = (path, data, options) => {
|
|
2373
|
+
appendFileSync$1(path, data, options);
|
|
2691
2374
|
};
|
|
2692
2375
|
const cp = async (source, destination, options) => {
|
|
2693
2376
|
await cp$1(source, destination, options);
|
|
@@ -2695,60 +2378,60 @@ const cp = async (source, destination, options) => {
|
|
|
2695
2378
|
const cpSync = (source, destination, options) => {
|
|
2696
2379
|
cpSync$1(source, destination, options);
|
|
2697
2380
|
};
|
|
2698
|
-
const exists = async (path
|
|
2699
|
-
return (await exists$1(path
|
|
2381
|
+
const exists = async (path) => {
|
|
2382
|
+
return (await exists$1(path)).isOk();
|
|
2700
2383
|
};
|
|
2701
|
-
const existsSync = (path
|
|
2702
|
-
return existsSync$1(path
|
|
2384
|
+
const existsSync = (path) => {
|
|
2385
|
+
return existsSync$1(path).isOk();
|
|
2703
2386
|
};
|
|
2704
|
-
const mkdir = async (path
|
|
2705
|
-
await mkdir$1(path
|
|
2387
|
+
const mkdir = async (path, options) => {
|
|
2388
|
+
await mkdir$1(path, options);
|
|
2706
2389
|
};
|
|
2707
|
-
const mkdirSync = (path
|
|
2708
|
-
mkdirSync$1(path
|
|
2390
|
+
const mkdirSync = (path, options) => {
|
|
2391
|
+
mkdirSync$1(path, options);
|
|
2709
2392
|
};
|
|
2710
|
-
async function readFile(path
|
|
2711
|
-
const result = await readFile$1(path
|
|
2393
|
+
async function readFile(path, options) {
|
|
2394
|
+
const result = await readFile$1(path, options);
|
|
2712
2395
|
if (result.isErr()) return void 0;
|
|
2713
2396
|
return result.unwrap(null);
|
|
2714
2397
|
}
|
|
2715
|
-
function readFileSync(path
|
|
2716
|
-
const result = readFileSync$1(path
|
|
2398
|
+
function readFileSync(path, options) {
|
|
2399
|
+
const result = readFileSync$1(path, options);
|
|
2717
2400
|
if (result.isErr()) return void 0;
|
|
2718
2401
|
return result.unwrap(null);
|
|
2719
2402
|
}
|
|
2720
|
-
const readFileByLine = async (path
|
|
2721
|
-
const result = await readFileByLine$1(path
|
|
2403
|
+
const readFileByLine = async (path, options) => {
|
|
2404
|
+
const result = await readFileByLine$1(path, options);
|
|
2722
2405
|
if (result.isErr()) return void 0;
|
|
2723
2406
|
return result.unwrap(null);
|
|
2724
2407
|
};
|
|
2725
|
-
const readJson = async (path
|
|
2726
|
-
const result = await readJson$1(path
|
|
2408
|
+
const readJson = async (path, options) => {
|
|
2409
|
+
const result = await readJson$1(path, options);
|
|
2727
2410
|
if (result.isErr()) return void 0;
|
|
2728
2411
|
return result.unwrap(null);
|
|
2729
2412
|
};
|
|
2730
|
-
const readJsonSync = (path
|
|
2731
|
-
const result = readJsonSync$1(path
|
|
2413
|
+
const readJsonSync = (path, options) => {
|
|
2414
|
+
const result = readJsonSync$1(path, options);
|
|
2732
2415
|
if (result.isErr()) return void 0;
|
|
2733
2416
|
return result.unwrap(null);
|
|
2734
2417
|
};
|
|
2735
|
-
const rm = async (path
|
|
2736
|
-
await rm$1(path
|
|
2418
|
+
const rm = async (path, options) => {
|
|
2419
|
+
await rm$1(path, options);
|
|
2737
2420
|
};
|
|
2738
|
-
const rmSync = (path
|
|
2739
|
-
rmSync$1(path
|
|
2421
|
+
const rmSync = (path, options) => {
|
|
2422
|
+
rmSync$1(path, options);
|
|
2740
2423
|
};
|
|
2741
|
-
const writeFile$1 = async (path
|
|
2742
|
-
await writeFile(path
|
|
2424
|
+
const writeFile$1 = async (path, data, options) => {
|
|
2425
|
+
await writeFile(path, data, options);
|
|
2743
2426
|
};
|
|
2744
|
-
const writeFileSync$1 = (path
|
|
2745
|
-
writeFileSync(path
|
|
2427
|
+
const writeFileSync$1 = (path, data, options) => {
|
|
2428
|
+
writeFileSync(path, data, options);
|
|
2746
2429
|
};
|
|
2747
|
-
const writeJson$1 = async (path
|
|
2748
|
-
await writeJson(path
|
|
2430
|
+
const writeJson$1 = async (path, data, indentOrOptions) => {
|
|
2431
|
+
await writeJson(path, data, indentOrOptions);
|
|
2749
2432
|
};
|
|
2750
|
-
const writeJsonSync$1 = (path
|
|
2751
|
-
writeJsonSync(path
|
|
2433
|
+
const writeJsonSync$1 = (path, data, indentOrOptions) => {
|
|
2434
|
+
writeJsonSync(path, data, indentOrOptions);
|
|
2752
2435
|
};
|
|
2753
2436
|
|
|
2754
2437
|
//#endregion
|
|
@@ -2765,68 +2448,37 @@ var VFile = class VFile {
|
|
|
2765
2448
|
});
|
|
2766
2449
|
}
|
|
2767
2450
|
content = "";
|
|
2768
|
-
/**
|
|
2769
|
-
* @example
|
|
2770
|
-
* `/home/user/project`
|
|
2771
|
-
*/
|
|
2772
2451
|
cwd = process.cwd();
|
|
2773
|
-
/**
|
|
2774
|
-
* @example
|
|
2775
|
-
* `src`
|
|
2776
|
-
*/
|
|
2777
2452
|
dirname = "";
|
|
2778
|
-
/**
|
|
2779
|
-
* @example
|
|
2780
|
-
* `index`
|
|
2781
|
-
*/
|
|
2782
2453
|
filename = "";
|
|
2783
|
-
/**
|
|
2784
|
-
* @example
|
|
2785
|
-
* `js`
|
|
2786
|
-
*/
|
|
2787
2454
|
extname = "";
|
|
2788
2455
|
constructor(options) {
|
|
2789
2456
|
const { pathname, content, cwd } = options;
|
|
2790
|
-
this.pathname = pathname;
|
|
2791
2457
|
if (content) this.content = content;
|
|
2792
2458
|
if (cwd) this.cwd = cwd;
|
|
2459
|
+
if (path$1.isAbsolute(pathname)) this.pathname = pathname;
|
|
2460
|
+
else this.relativePathname = pathname;
|
|
2793
2461
|
}
|
|
2794
|
-
/**
|
|
2795
|
-
* @example
|
|
2796
|
-
* `/home/user/project/src/index.js`
|
|
2797
|
-
*/
|
|
2798
2462
|
get pathname() {
|
|
2799
2463
|
return path$1.resolve(this.cwd, this.dirname, this.basename);
|
|
2800
2464
|
}
|
|
2801
2465
|
set pathname(value) {
|
|
2802
2466
|
this.parse(value);
|
|
2803
2467
|
}
|
|
2804
|
-
/**
|
|
2805
|
-
* @example
|
|
2806
|
-
* `index.js`
|
|
2807
|
-
*/
|
|
2808
2468
|
get basename() {
|
|
2809
|
-
return this.filename + "." + this.extname;
|
|
2469
|
+
return this.extname ? this.filename + "." + this.extname : this.filename;
|
|
2810
2470
|
}
|
|
2811
2471
|
set basename(value) {
|
|
2812
2472
|
const { name, ext } = path$1.parse(value);
|
|
2813
2473
|
this.filename = name;
|
|
2814
|
-
this.extname = removePrefix(
|
|
2474
|
+
this.extname = removePrefix(".", ext);
|
|
2815
2475
|
}
|
|
2816
|
-
/**
|
|
2817
|
-
* @example
|
|
2818
|
-
* `/home/user/project/src`
|
|
2819
|
-
*/
|
|
2820
2476
|
get absoluteDirname() {
|
|
2821
2477
|
return path$1.resolve(this.cwd, this.dirname);
|
|
2822
2478
|
}
|
|
2823
2479
|
set absoluteDirname(value) {
|
|
2824
2480
|
this.dirname = path$1.relative(this.cwd, value);
|
|
2825
2481
|
}
|
|
2826
|
-
/**
|
|
2827
|
-
* @example
|
|
2828
|
-
* `src/index.js`
|
|
2829
|
-
*/
|
|
2830
2482
|
get relativePathname() {
|
|
2831
2483
|
return path$1.relative(this.cwd, this.pathname);
|
|
2832
2484
|
}
|
|
@@ -2841,9 +2493,10 @@ var VFile = class VFile {
|
|
|
2841
2493
|
});
|
|
2842
2494
|
}
|
|
2843
2495
|
parse(value) {
|
|
2496
|
+
const { name, ext } = path$1.parse(value);
|
|
2844
2497
|
this.dirname = path$1.relative(this.cwd, path$1.dirname(value));
|
|
2845
|
-
this.
|
|
2846
|
-
this.
|
|
2498
|
+
this.filename = name;
|
|
2499
|
+
this.extname = removePrefix(".", ext);
|
|
2847
2500
|
}
|
|
2848
2501
|
};
|
|
2849
2502
|
|