@pnpm/exe 11.0.0-rc.0 → 11.0.0-rc.2

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.
Files changed (29) hide show
  1. package/dist/node_modules/lru-cache/dist/commonjs/diagnostics-channel.js +10 -0
  2. package/dist/node_modules/lru-cache/dist/commonjs/index.js +227 -130
  3. package/dist/node_modules/lru-cache/dist/commonjs/index.min.js +1 -1
  4. package/dist/node_modules/lru-cache/dist/esm/browser/diagnostics-channel.js +4 -0
  5. package/dist/node_modules/lru-cache/dist/esm/browser/index.js +1688 -0
  6. package/dist/node_modules/lru-cache/dist/esm/browser/index.min.js +2 -0
  7. package/dist/node_modules/lru-cache/dist/esm/diagnostics-channel.js +19 -0
  8. package/dist/node_modules/lru-cache/dist/esm/index.js +227 -130
  9. package/dist/node_modules/lru-cache/dist/esm/index.min.js +1 -1
  10. package/dist/node_modules/lru-cache/dist/esm/node/diagnostics-channel.js +7 -0
  11. package/dist/node_modules/lru-cache/dist/esm/node/index.js +1688 -0
  12. package/dist/node_modules/lru-cache/dist/esm/node/index.min.js +2 -0
  13. package/dist/node_modules/lru-cache/package.json +42 -9
  14. package/dist/node_modules/minimatch/dist/commonjs/ast.js +9 -10
  15. package/dist/node_modules/minimatch/dist/commonjs/index.js +26 -20
  16. package/dist/node_modules/minimatch/dist/commonjs/unescape.js +6 -6
  17. package/dist/node_modules/minimatch/dist/esm/ast.js +9 -10
  18. package/dist/node_modules/minimatch/dist/esm/index.js +26 -20
  19. package/dist/node_modules/minimatch/dist/esm/unescape.js +6 -6
  20. package/dist/node_modules/minimatch/package.json +14 -8
  21. package/dist/node_modules/minipass-flush/package.json +6 -3
  22. package/dist/node_modules/tinyglobby/dist/index.cjs +132 -148
  23. package/dist/node_modules/tinyglobby/dist/index.d.cts +33 -32
  24. package/dist/node_modules/tinyglobby/dist/index.d.mts +33 -32
  25. package/dist/node_modules/tinyglobby/dist/index.mjs +134 -146
  26. package/dist/node_modules/tinyglobby/package.json +10 -10
  27. package/dist/pnpm.mjs +10126 -8751
  28. package/package.json +9 -9
  29. package/dist/node_modules/minipass-flush/LICENSE +0 -15
@@ -1,4 +1,5 @@
1
- //#region rolldown:runtime
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region \0rolldown/runtime.js
2
3
  var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -19,51 +20,45 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
19
20
  value: mod,
20
21
  enumerable: true
21
22
  }) : target, mod));
22
-
23
23
  //#endregion
24
24
  let fs = require("fs");
25
- fs = __toESM(fs);
26
25
  let path = require("path");
27
- path = __toESM(path);
28
26
  let url = require("url");
29
- url = __toESM(url);
30
27
  let fdir = require("fdir");
31
- fdir = __toESM(fdir);
32
28
  let picomatch = require("picomatch");
33
29
  picomatch = __toESM(picomatch);
34
-
35
30
  //#region src/utils.ts
36
31
  const isReadonlyArray = Array.isArray;
32
+ const BACKSLASHES = /\\/g;
37
33
  const isWin = process.platform === "win32";
38
34
  const ONLY_PARENT_DIRECTORIES = /^(\/?\.\.)+$/;
39
35
  function getPartialMatcher(patterns, options = {}) {
40
36
  const patternsCount = patterns.length;
41
37
  const patternsParts = Array(patternsCount);
42
38
  const matchers = Array(patternsCount);
43
- const globstarEnabled = !options.noglobstar;
44
- for (let i = 0; i < patternsCount; i++) {
39
+ let i, j;
40
+ for (i = 0; i < patternsCount; i++) {
45
41
  const parts = splitPattern(patterns[i]);
46
42
  patternsParts[i] = parts;
47
43
  const partsCount = parts.length;
48
44
  const partMatchers = Array(partsCount);
49
- for (let j = 0; j < partsCount; j++) partMatchers[j] = (0, picomatch.default)(parts[j], options);
45
+ for (j = 0; j < partsCount; j++) partMatchers[j] = (0, picomatch.default)(parts[j], options);
50
46
  matchers[i] = partMatchers;
51
47
  }
52
48
  return (input) => {
53
49
  const inputParts = input.split("/");
54
50
  if (inputParts[0] === ".." && ONLY_PARENT_DIRECTORIES.test(input)) return true;
55
- for (let i = 0; i < patterns.length; i++) {
51
+ for (i = 0; i < patternsCount; i++) {
56
52
  const patternParts = patternsParts[i];
57
53
  const matcher = matchers[i];
58
54
  const inputPatternCount = inputParts.length;
59
55
  const minParts = Math.min(inputPatternCount, patternParts.length);
60
- let j = 0;
56
+ j = 0;
61
57
  while (j < minParts) {
62
58
  const part = patternParts[j];
63
59
  if (part.includes("/")) return true;
64
- const match = matcher[j](inputParts[j]);
65
- if (!match) break;
66
- if (globstarEnabled && part === "**") return true;
60
+ if (!matcher[j](inputParts[j])) break;
61
+ if (!options.noglobstar && part === "**") return true;
67
62
  j++;
68
63
  }
69
64
  if (j === inputPatternCount) return true;
@@ -77,7 +72,7 @@ const isRoot = isWin ? (p) => WIN32_ROOT_DIR.test(p) : (p) => p === "/";
77
72
  function buildFormat(cwd, root, absolute) {
78
73
  if (cwd === root || root.startsWith(`${cwd}/`)) {
79
74
  if (absolute) {
80
- const start = isRoot(cwd) ? cwd.length : cwd.length + 1;
75
+ const start = cwd.length + +!isRoot(cwd);
81
76
  return (p, isDir) => p.slice(start, isDir ? -1 : void 0) || ".";
82
77
  }
83
78
  const prefix = root.slice(cwd.length + 1);
@@ -98,22 +93,21 @@ function buildRelative(cwd, root) {
98
93
  }
99
94
  return (p) => {
100
95
  const result = path.posix.relative(cwd, `${root}/${p}`);
101
- if (p.endsWith("/") && result !== "") return `${result}/`;
102
- return result || ".";
96
+ return p[p.length - 1] === "/" && result !== "" ? `${result}/` : result || ".";
103
97
  };
104
98
  }
105
99
  const splitPatternOptions = { parts: true };
106
- function splitPattern(path$2) {
100
+ function splitPattern(path$1) {
107
101
  var _result$parts;
108
- const result = picomatch.default.scan(path$2, splitPatternOptions);
109
- return ((_result$parts = result.parts) === null || _result$parts === void 0 ? void 0 : _result$parts.length) ? result.parts : [path$2];
102
+ const result = picomatch.default.scan(path$1, splitPatternOptions);
103
+ return ((_result$parts = result.parts) === null || _result$parts === void 0 ? void 0 : _result$parts.length) ? result.parts : [path$1];
110
104
  }
111
105
  const ESCAPED_WIN32_BACKSLASHES = /\\(?![()[\]{}!+@])/g;
112
106
  function convertPosixPathToPattern(path$2) {
113
107
  return escapePosixPath(path$2);
114
108
  }
115
- function convertWin32PathToPattern(path$2) {
116
- return escapeWin32Path(path$2).replace(ESCAPED_WIN32_BACKSLASHES, "/");
109
+ function convertWin32PathToPattern(path$3) {
110
+ return escapeWin32Path(path$3).replace(ESCAPED_WIN32_BACKSLASHES, "/");
117
111
  }
118
112
  /**
119
113
  * Converts a path to a pattern depending on the platform.
@@ -124,8 +118,8 @@ function convertWin32PathToPattern(path$2) {
124
118
  const convertPathToPattern = isWin ? convertWin32PathToPattern : convertPosixPathToPattern;
125
119
  const POSIX_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g;
126
120
  const WIN32_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g;
127
- const escapePosixPath = (path$2) => path$2.replace(POSIX_UNESCAPED_GLOB_SYMBOLS, "\\$&");
128
- const escapeWin32Path = (path$2) => path$2.replace(WIN32_UNESCAPED_GLOB_SYMBOLS, "\\$&");
121
+ const escapePosixPath = (path$4) => path$4.replace(POSIX_UNESCAPED_GLOB_SYMBOLS, "\\$&");
122
+ const escapeWin32Path = (path$5) => path$5.replace(WIN32_UNESCAPED_GLOB_SYMBOLS, "\\$&");
129
123
  /**
130
124
  * Escapes a path's special characters depending on the platform.
131
125
  * @see {@link https://superchupu.dev/tinyglobby/documentation#escapePath}
@@ -152,31 +146,33 @@ function isDynamicPattern(pattern, options) {
152
146
  function log(...tasks) {
153
147
  console.log(`[tinyglobby ${(/* @__PURE__ */ new Date()).toLocaleTimeString("es")}]`, ...tasks);
154
148
  }
155
-
149
+ function ensureStringArray(value) {
150
+ return typeof value === "string" ? [value] : value !== null && value !== void 0 ? value : [];
151
+ }
156
152
  //#endregion
157
- //#region src/index.ts
153
+ //#region src/patterns.ts
158
154
  const PARENT_DIRECTORY = /^(\/?\.\.)+/;
159
155
  const ESCAPING_BACKSLASHES = /\\(?=[()[\]{}!*+?@|])/g;
160
- const BACKSLASHES = /\\/g;
161
- function normalizePattern(pattern, expandDirectories, cwd, props, isIgnore) {
156
+ function normalizePattern(pattern, opts, props, isIgnore) {
157
+ var _PARENT_DIRECTORY$exe;
158
+ const cwd = opts.cwd;
162
159
  let result = pattern;
163
- if (pattern.endsWith("/")) result = pattern.slice(0, -1);
164
- if (!result.endsWith("*") && expandDirectories) result += "/**";
160
+ if (pattern[pattern.length - 1] === "/") result = pattern.slice(0, -1);
161
+ if (result[result.length - 1] !== "*" && opts.expandDirectories) result += "/**";
165
162
  const escapedCwd = escapePath(cwd);
166
- if (path.default.isAbsolute(result.replace(ESCAPING_BACKSLASHES, ""))) result = path.posix.relative(escapedCwd, result);
167
- else result = path.posix.normalize(result);
168
- const parentDirectoryMatch = PARENT_DIRECTORY.exec(result);
163
+ result = (0, path.isAbsolute)(result.replace(ESCAPING_BACKSLASHES, "")) ? path.posix.relative(escapedCwd, result) : path.posix.normalize(result);
164
+ const parentDir = (_PARENT_DIRECTORY$exe = PARENT_DIRECTORY.exec(result)) === null || _PARENT_DIRECTORY$exe === void 0 ? void 0 : _PARENT_DIRECTORY$exe[0];
169
165
  const parts = splitPattern(result);
170
- if (parentDirectoryMatch === null || parentDirectoryMatch === void 0 ? void 0 : parentDirectoryMatch[0]) {
171
- const n = (parentDirectoryMatch[0].length + 1) / 3;
166
+ if (parentDir) {
167
+ const n = (parentDir.length + 1) / 3;
172
168
  let i = 0;
173
169
  const cwdParts = escapedCwd.split("/");
174
170
  while (i < n && parts[i + n] === cwdParts[cwdParts.length + i - n]) {
175
171
  result = result.slice(0, (n - i - 1) * 3) + result.slice((n - i) * 3 + parts[i + n].length + 1) || ".";
176
172
  i++;
177
173
  }
178
- const potentialRoot = path.posix.join(cwd, parentDirectoryMatch[0].slice(i * 3));
179
- if (!potentialRoot.startsWith(".") && props.root.length > potentialRoot.length) {
174
+ const potentialRoot = path.posix.join(cwd, parentDir.slice(i * 3));
175
+ if (potentialRoot[0] !== "." && props.root.length > potentialRoot.length) {
180
176
  props.root = potentialRoot;
181
177
  props.depthOffset = -n + i;
182
178
  }
@@ -192,7 +188,7 @@ function normalizePattern(pattern, expandDirectories, cwd, props, isIgnore) {
192
188
  newCommonPath.pop();
193
189
  break;
194
190
  }
195
- if (part !== props.commonPath[i] || isDynamicPattern(part) || i === parts.length - 1) break;
191
+ if (i === parts.length - 1 || part !== props.commonPath[i] || isDynamicPattern(part)) break;
196
192
  newCommonPath.push(part);
197
193
  }
198
194
  props.depthOffset = newCommonPath.length;
@@ -201,150 +197,138 @@ function normalizePattern(pattern, expandDirectories, cwd, props, isIgnore) {
201
197
  }
202
198
  return result;
203
199
  }
204
- function processPatterns({ patterns = ["**/*"], ignore = [], expandDirectories = true }, cwd, props) {
205
- if (typeof patterns === "string") patterns = [patterns];
206
- if (typeof ignore === "string") ignore = [ignore];
200
+ function processPatterns(options, patterns, props) {
207
201
  const matchPatterns = [];
208
202
  const ignorePatterns = [];
209
- for (const pattern of ignore) {
203
+ for (const pattern of options.ignore) {
210
204
  if (!pattern) continue;
211
- if (pattern[0] !== "!" || pattern[1] === "(") ignorePatterns.push(normalizePattern(pattern, expandDirectories, cwd, props, true));
205
+ if (pattern[0] !== "!" || pattern[1] === "(") ignorePatterns.push(normalizePattern(pattern, options, props, true));
212
206
  }
213
207
  for (const pattern of patterns) {
214
208
  if (!pattern) continue;
215
- if (pattern[0] !== "!" || pattern[1] === "(") matchPatterns.push(normalizePattern(pattern, expandDirectories, cwd, props, false));
216
- else if (pattern[1] !== "!" || pattern[2] === "(") ignorePatterns.push(normalizePattern(pattern.slice(1), expandDirectories, cwd, props, true));
209
+ if (pattern[0] !== "!" || pattern[1] === "(") matchPatterns.push(normalizePattern(pattern, options, props, false));
210
+ else if (pattern[1] !== "!" || pattern[2] === "(") ignorePatterns.push(normalizePattern(pattern.slice(1), options, props, true));
217
211
  }
218
212
  return {
219
213
  match: matchPatterns,
220
214
  ignore: ignorePatterns
221
215
  };
222
216
  }
223
- function formatPaths(paths, relative) {
224
- for (let i = paths.length - 1; i >= 0; i--) {
225
- const path$2 = paths[i];
226
- paths[i] = relative(path$2);
227
- }
228
- return paths;
229
- }
230
- function normalizeCwd(cwd) {
231
- if (!cwd) return process.cwd().replace(BACKSLASHES, "/");
232
- if (cwd instanceof URL) return (0, url.fileURLToPath)(cwd).replace(BACKSLASHES, "/");
233
- return path.default.resolve(cwd).replace(BACKSLASHES, "/");
234
- }
235
- function getCrawler(patterns, inputOptions = {}) {
236
- const options = process.env.TINYGLOBBY_DEBUG ? {
237
- ...inputOptions,
238
- debug: true
239
- } : inputOptions;
240
- const cwd = normalizeCwd(options.cwd);
241
- if (options.debug) log("globbing with:", {
242
- patterns,
243
- options,
244
- cwd
245
- });
246
- if (Array.isArray(patterns) && patterns.length === 0) return [{
247
- sync: () => [],
248
- withPromise: async () => []
249
- }, false];
217
+ //#endregion
218
+ //#region src/crawler.ts
219
+ function buildCrawler(options, patterns) {
220
+ const cwd = options.cwd;
250
221
  const props = {
251
222
  root: cwd,
252
- commonPath: null,
253
223
  depthOffset: 0
254
224
  };
255
- const processed = processPatterns({
256
- ...options,
257
- patterns
258
- }, cwd, props);
225
+ const processed = processPatterns(options, patterns, props);
259
226
  if (options.debug) log("internal processing patterns:", processed);
227
+ const { absolute, caseSensitiveMatch, debug, dot, followSymbolicLinks, onlyDirectories } = options;
228
+ const root = props.root.replace(BACKSLASHES, "");
260
229
  const matchOptions = {
261
- dot: options.dot,
230
+ dot,
262
231
  nobrace: options.braceExpansion === false,
263
- nocase: options.caseSensitiveMatch === false,
232
+ nocase: !caseSensitiveMatch,
264
233
  noextglob: options.extglob === false,
265
234
  noglobstar: options.globstar === false,
266
235
  posix: true
267
236
  };
268
- const matcher = (0, picomatch.default)(processed.match, {
269
- ...matchOptions,
270
- ignore: processed.ignore
271
- });
237
+ const matcher = (0, picomatch.default)(processed.match, matchOptions);
272
238
  const ignore = (0, picomatch.default)(processed.ignore, matchOptions);
273
239
  const partialMatcher = getPartialMatcher(processed.match, matchOptions);
274
- const format = buildFormat(cwd, props.root, options.absolute);
275
- const formatExclude = options.absolute ? format : buildFormat(cwd, props.root, true);
276
- const fdirOptions = {
277
- filters: [options.debug ? (p, isDirectory) => {
278
- const path$2 = format(p, isDirectory);
279
- const matches = matcher(path$2);
280
- if (matches) log(`matched ${path$2}`);
240
+ const format = buildFormat(cwd, root, absolute);
241
+ const excludeFormatter = absolute ? format : buildFormat(cwd, root, true);
242
+ const excludePredicate = (_, p) => {
243
+ const relativePath = excludeFormatter(p, true);
244
+ return relativePath !== "." && !partialMatcher(relativePath) || ignore(relativePath);
245
+ };
246
+ let maxDepth;
247
+ if (options.deep !== void 0) maxDepth = Math.round(options.deep - props.depthOffset);
248
+ const crawler = new fdir.fdir({
249
+ filters: [debug ? (p, isDirectory) => {
250
+ const path = format(p, isDirectory);
251
+ const matches = matcher(path) && !ignore(path);
252
+ if (matches) log(`matched ${path}`);
281
253
  return matches;
282
- } : (p, isDirectory) => matcher(format(p, isDirectory))],
283
- exclude: options.debug ? (_, p) => {
284
- const relativePath = formatExclude(p, true);
285
- const skipped = relativePath !== "." && !partialMatcher(relativePath) || ignore(relativePath);
286
- if (skipped) log(`skipped ${p}`);
287
- else log(`crawling ${p}`);
254
+ } : (p, isDirectory) => {
255
+ const path = format(p, isDirectory);
256
+ return matcher(path) && !ignore(path);
257
+ }],
258
+ exclude: debug ? (_, p) => {
259
+ const skipped = excludePredicate(_, p);
260
+ log(`${skipped ? "skipped" : "crawling"} ${p}`);
288
261
  return skipped;
289
- } : (_, p) => {
290
- const relativePath = formatExclude(p, true);
291
- return relativePath !== "." && !partialMatcher(relativePath) || ignore(relativePath);
292
- },
293
- fs: options.fs ? {
294
- readdir: options.fs.readdir || fs.default.readdir,
295
- readdirSync: options.fs.readdirSync || fs.default.readdirSync,
296
- realpath: options.fs.realpath || fs.default.realpath,
297
- realpathSync: options.fs.realpathSync || fs.default.realpathSync,
298
- stat: options.fs.stat || fs.default.stat,
299
- statSync: options.fs.statSync || fs.default.statSync
300
- } : void 0,
262
+ } : excludePredicate,
263
+ fs: options.fs,
301
264
  pathSeparator: "/",
302
- relativePaths: true,
303
- resolveSymlinks: true,
265
+ relativePaths: !absolute,
266
+ resolvePaths: absolute,
267
+ includeBasePath: absolute,
268
+ resolveSymlinks: followSymbolicLinks,
269
+ excludeSymlinks: !followSymbolicLinks,
270
+ excludeFiles: onlyDirectories,
271
+ includeDirs: onlyDirectories || !options.onlyFiles,
272
+ maxDepth,
304
273
  signal: options.signal
274
+ }).crawl(root);
275
+ if (options.debug) log("internal properties:", {
276
+ ...props,
277
+ root
278
+ });
279
+ return [crawler, cwd !== root && !absolute && buildRelative(cwd, root)];
280
+ }
281
+ //#endregion
282
+ //#region src/index.ts
283
+ function formatPaths(paths, mapper) {
284
+ if (mapper) for (let i = paths.length - 1; i >= 0; i--) paths[i] = mapper(paths[i]);
285
+ return paths;
286
+ }
287
+ const defaultOptions = {
288
+ caseSensitiveMatch: true,
289
+ cwd: process.cwd(),
290
+ debug: !!process.env.TINYGLOBBY_DEBUG,
291
+ expandDirectories: true,
292
+ followSymbolicLinks: true,
293
+ onlyFiles: true
294
+ };
295
+ function getOptions(options) {
296
+ const opts = {
297
+ ...defaultOptions,
298
+ ...options
305
299
  };
306
- if (options.deep !== void 0) fdirOptions.maxDepth = Math.round(options.deep - props.depthOffset);
307
- if (options.absolute) {
308
- fdirOptions.relativePaths = false;
309
- fdirOptions.resolvePaths = true;
310
- fdirOptions.includeBasePath = true;
311
- }
312
- if (options.followSymbolicLinks === false) {
313
- fdirOptions.resolveSymlinks = false;
314
- fdirOptions.excludeSymlinks = true;
315
- }
316
- if (options.onlyDirectories) {
317
- fdirOptions.excludeFiles = true;
318
- fdirOptions.includeDirs = true;
319
- } else if (options.onlyFiles === false) fdirOptions.includeDirs = true;
320
- props.root = props.root.replace(BACKSLASHES, "");
321
- const root = props.root;
322
- if (options.debug) log("internal properties:", props);
323
- const relative = cwd !== root && !options.absolute && buildRelative(cwd, props.root);
324
- return [new fdir.fdir(fdirOptions).crawl(root), relative];
300
+ opts.cwd = (opts.cwd instanceof URL ? (0, url.fileURLToPath)(opts.cwd) : (0, path.resolve)(opts.cwd)).replace(BACKSLASHES, "/");
301
+ opts.ignore = ensureStringArray(opts.ignore);
302
+ opts.fs && (opts.fs = {
303
+ readdir: opts.fs.readdir || fs.readdir,
304
+ readdirSync: opts.fs.readdirSync || fs.readdirSync,
305
+ realpath: opts.fs.realpath || fs.realpath,
306
+ realpathSync: opts.fs.realpathSync || fs.realpathSync,
307
+ stat: opts.fs.stat || fs.stat,
308
+ statSync: opts.fs.statSync || fs.statSync
309
+ });
310
+ if (opts.debug) log("globbing with options:", opts);
311
+ return opts;
312
+ }
313
+ function getCrawler(globInput, inputOptions = {}) {
314
+ var _ref;
315
+ if (globInput && (inputOptions === null || inputOptions === void 0 ? void 0 : inputOptions.patterns)) throw new Error("Cannot pass patterns as both an argument and an option");
316
+ const isModern = isReadonlyArray(globInput) || typeof globInput === "string";
317
+ const patterns = ensureStringArray((_ref = isModern ? globInput : globInput.patterns) !== null && _ref !== void 0 ? _ref : "**/*");
318
+ const options = getOptions(isModern ? inputOptions : globInput);
319
+ return patterns.length > 0 ? buildCrawler(options, patterns) : [];
325
320
  }
326
- async function glob(patternsOrOptions, options) {
327
- if (patternsOrOptions && (options === null || options === void 0 ? void 0 : options.patterns)) throw new Error("Cannot pass patterns as both an argument and an option");
328
- const isModern = isReadonlyArray(patternsOrOptions) || typeof patternsOrOptions === "string";
329
- const opts = isModern ? options : patternsOrOptions;
330
- const patterns = isModern ? patternsOrOptions : patternsOrOptions.patterns;
331
- const [crawler, relative] = getCrawler(patterns, opts);
332
- if (!relative) return crawler.withPromise();
333
- return formatPaths(await crawler.withPromise(), relative);
321
+ async function glob(globInput, options) {
322
+ const [crawler, relative] = getCrawler(globInput, options);
323
+ return crawler ? formatPaths(await crawler.withPromise(), relative) : [];
334
324
  }
335
- function globSync(patternsOrOptions, options) {
336
- if (patternsOrOptions && (options === null || options === void 0 ? void 0 : options.patterns)) throw new Error("Cannot pass patterns as both an argument and an option");
337
- const isModern = isReadonlyArray(patternsOrOptions) || typeof patternsOrOptions === "string";
338
- const opts = isModern ? options : patternsOrOptions;
339
- const patterns = isModern ? patternsOrOptions : patternsOrOptions.patterns;
340
- const [crawler, relative] = getCrawler(patterns, opts);
341
- if (!relative) return crawler.sync();
342
- return formatPaths(crawler.sync(), relative);
325
+ function globSync(globInput, options) {
326
+ const [crawler, relative] = getCrawler(globInput, options);
327
+ return crawler ? formatPaths(crawler.sync(), relative) : [];
343
328
  }
344
-
345
329
  //#endregion
346
330
  exports.convertPathToPattern = convertPathToPattern;
347
331
  exports.escapePath = escapePath;
348
332
  exports.glob = glob;
349
333
  exports.globSync = globSync;
350
- exports.isDynamicPattern = isDynamicPattern;
334
+ exports.isDynamicPattern = isDynamicPattern;
@@ -1,35 +1,7 @@
1
1
  import { FSLike } from "fdir";
2
2
 
3
- //#region src/utils.d.ts
4
-
5
- /**
6
- * Converts a path to a pattern depending on the platform.
7
- * Identical to {@link escapePath} on POSIX systems.
8
- * @see {@link https://superchupu.dev/tinyglobby/documentation#convertPathToPattern}
9
- */
10
- declare const convertPathToPattern: (path: string) => string;
11
- /**
12
- * Escapes a path's special characters depending on the platform.
13
- * @see {@link https://superchupu.dev/tinyglobby/documentation#escapePath}
14
- */
15
- declare const escapePath: (path: string) => string;
16
- /**
17
- * Checks if a pattern has dynamic parts.
18
- *
19
- * Has a few minor differences with [`fast-glob`](https://github.com/mrmlnc/fast-glob) for better accuracy:
20
- *
21
- * - Doesn't necessarily return `false` on patterns that include `\`.
22
- * - Returns `true` if the pattern includes parentheses, regardless of them representing one single pattern or not.
23
- * - Returns `true` for unfinished glob extensions i.e. `(h`, `+(h`.
24
- * - Returns `true` for unfinished brace expansions as long as they include `,` or `..`.
25
- *
26
- * @see {@link https://superchupu.dev/tinyglobby/documentation#isDynamicPattern}
27
- */
28
- declare function isDynamicPattern(pattern: string, options?: {
29
- caseSensitiveMatch: boolean;
30
- }): boolean;
31
- //#endregion
32
- //#region src/index.d.ts
3
+ //#region src/types.d.ts
4
+ type FileSystemAdapter = Partial<FSLike>;
33
5
  interface GlobOptions {
34
6
  /**
35
7
  * Whether to return absolute paths. Disable to have relative paths.
@@ -124,7 +96,36 @@ interface GlobOptions {
124
96
  */
125
97
  signal?: AbortSignal;
126
98
  }
127
- type FileSystemAdapter = Partial<FSLike>;
99
+ //#endregion
100
+ //#region src/utils.d.ts
101
+ /**
102
+ * Converts a path to a pattern depending on the platform.
103
+ * Identical to {@link escapePath} on POSIX systems.
104
+ * @see {@link https://superchupu.dev/tinyglobby/documentation#convertPathToPattern}
105
+ */
106
+ declare const convertPathToPattern: (path: string) => string;
107
+ /**
108
+ * Escapes a path's special characters depending on the platform.
109
+ * @see {@link https://superchupu.dev/tinyglobby/documentation#escapePath}
110
+ */
111
+ declare const escapePath: (path: string) => string;
112
+ /**
113
+ * Checks if a pattern has dynamic parts.
114
+ *
115
+ * Has a few minor differences with [`fast-glob`](https://github.com/mrmlnc/fast-glob) for better accuracy:
116
+ *
117
+ * - Doesn't necessarily return `false` on patterns that include `\`.
118
+ * - Returns `true` if the pattern includes parentheses, regardless of them representing one single pattern or not.
119
+ * - Returns `true` for unfinished glob extensions i.e. `(h`, `+(h`.
120
+ * - Returns `true` for unfinished brace expansions as long as they include `,` or `..`.
121
+ *
122
+ * @see {@link https://superchupu.dev/tinyglobby/documentation#isDynamicPattern}
123
+ */
124
+ declare function isDynamicPattern(pattern: string, options?: {
125
+ caseSensitiveMatch: boolean;
126
+ }): boolean;
127
+ //#endregion
128
+ //#region src/index.d.ts
128
129
  /**
129
130
  * Asynchronously match files following a glob pattern.
130
131
  * @see {@link https://superchupu.dev/tinyglobby/documentation#glob}
@@ -144,4 +145,4 @@ declare function globSync(patterns: string | readonly string[], options?: Omit<G
144
145
  */
145
146
  declare function globSync(options: GlobOptions): string[];
146
147
  //#endregion
147
- export { FileSystemAdapter, GlobOptions, convertPathToPattern, escapePath, glob, globSync, isDynamicPattern };
148
+ export { type GlobOptions, convertPathToPattern, escapePath, glob, globSync, isDynamicPattern };
@@ -1,35 +1,7 @@
1
1
  import { FSLike } from "fdir";
2
2
 
3
- //#region src/utils.d.ts
4
-
5
- /**
6
- * Converts a path to a pattern depending on the platform.
7
- * Identical to {@link escapePath} on POSIX systems.
8
- * @see {@link https://superchupu.dev/tinyglobby/documentation#convertPathToPattern}
9
- */
10
- declare const convertPathToPattern: (path: string) => string;
11
- /**
12
- * Escapes a path's special characters depending on the platform.
13
- * @see {@link https://superchupu.dev/tinyglobby/documentation#escapePath}
14
- */
15
- declare const escapePath: (path: string) => string;
16
- /**
17
- * Checks if a pattern has dynamic parts.
18
- *
19
- * Has a few minor differences with [`fast-glob`](https://github.com/mrmlnc/fast-glob) for better accuracy:
20
- *
21
- * - Doesn't necessarily return `false` on patterns that include `\`.
22
- * - Returns `true` if the pattern includes parentheses, regardless of them representing one single pattern or not.
23
- * - Returns `true` for unfinished glob extensions i.e. `(h`, `+(h`.
24
- * - Returns `true` for unfinished brace expansions as long as they include `,` or `..`.
25
- *
26
- * @see {@link https://superchupu.dev/tinyglobby/documentation#isDynamicPattern}
27
- */
28
- declare function isDynamicPattern(pattern: string, options?: {
29
- caseSensitiveMatch: boolean;
30
- }): boolean;
31
- //#endregion
32
- //#region src/index.d.ts
3
+ //#region src/types.d.ts
4
+ type FileSystemAdapter = Partial<FSLike>;
33
5
  interface GlobOptions {
34
6
  /**
35
7
  * Whether to return absolute paths. Disable to have relative paths.
@@ -124,7 +96,36 @@ interface GlobOptions {
124
96
  */
125
97
  signal?: AbortSignal;
126
98
  }
127
- type FileSystemAdapter = Partial<FSLike>;
99
+ //#endregion
100
+ //#region src/utils.d.ts
101
+ /**
102
+ * Converts a path to a pattern depending on the platform.
103
+ * Identical to {@link escapePath} on POSIX systems.
104
+ * @see {@link https://superchupu.dev/tinyglobby/documentation#convertPathToPattern}
105
+ */
106
+ declare const convertPathToPattern: (path: string) => string;
107
+ /**
108
+ * Escapes a path's special characters depending on the platform.
109
+ * @see {@link https://superchupu.dev/tinyglobby/documentation#escapePath}
110
+ */
111
+ declare const escapePath: (path: string) => string;
112
+ /**
113
+ * Checks if a pattern has dynamic parts.
114
+ *
115
+ * Has a few minor differences with [`fast-glob`](https://github.com/mrmlnc/fast-glob) for better accuracy:
116
+ *
117
+ * - Doesn't necessarily return `false` on patterns that include `\`.
118
+ * - Returns `true` if the pattern includes parentheses, regardless of them representing one single pattern or not.
119
+ * - Returns `true` for unfinished glob extensions i.e. `(h`, `+(h`.
120
+ * - Returns `true` for unfinished brace expansions as long as they include `,` or `..`.
121
+ *
122
+ * @see {@link https://superchupu.dev/tinyglobby/documentation#isDynamicPattern}
123
+ */
124
+ declare function isDynamicPattern(pattern: string, options?: {
125
+ caseSensitiveMatch: boolean;
126
+ }): boolean;
127
+ //#endregion
128
+ //#region src/index.d.ts
128
129
  /**
129
130
  * Asynchronously match files following a glob pattern.
130
131
  * @see {@link https://superchupu.dev/tinyglobby/documentation#glob}
@@ -144,4 +145,4 @@ declare function globSync(patterns: string | readonly string[], options?: Omit<G
144
145
  */
145
146
  declare function globSync(options: GlobOptions): string[];
146
147
  //#endregion
147
- export { FileSystemAdapter, GlobOptions, convertPathToPattern, escapePath, glob, globSync, isDynamicPattern };
148
+ export { type GlobOptions, convertPathToPattern, escapePath, glob, globSync, isDynamicPattern };