@biffo/cli 0.199.9 → 0.200.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.
Files changed (2) hide show
  1. package/dist/index.js +24 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -320,11 +320,30 @@ function readCoreManifest(templateRoot) {
320
320
  }
321
321
  return result.data;
322
322
  }
323
- function matchLength(relPath, prefix) {
324
- if (prefix.endsWith("/")) {
325
- return relPath === prefix.slice(0, -1) || relPath.startsWith(prefix) ? prefix.length : -1;
326
- }
327
- return relPath === prefix ? prefix.length : -1;
323
+ function globToRegExp(pattern) {
324
+ const source = pattern.split("*").map((part) => part.replace(/[.+?^${}()|[\]\\]/g, "\\$&")).join("[^/]*");
325
+ return new RegExp(`^${source}$`);
326
+ }
327
+ var GLOB_CACHE = /* @__PURE__ */ new Map();
328
+ function globMatches(relPath, pattern) {
329
+ let re = GLOB_CACHE.get(pattern);
330
+ if (!re) {
331
+ re = globToRegExp(pattern);
332
+ GLOB_CACHE.set(pattern, re);
333
+ }
334
+ return re.test(relPath);
335
+ }
336
+ function matchLength(relPath, pattern) {
337
+ if (pattern.includes("*")) {
338
+ if (!globMatches(relPath, pattern)) return -1;
339
+ let literals = 0;
340
+ for (const ch of pattern) if (ch !== "*") literals++;
341
+ return literals;
342
+ }
343
+ if (pattern.endsWith("/")) {
344
+ return relPath === pattern.slice(0, -1) || relPath.startsWith(pattern) ? pattern.length : -1;
345
+ }
346
+ return relPath === pattern ? pattern.length : -1;
328
347
  }
329
348
  function longestMatch(relPath, prefixes) {
330
349
  let best = -1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@biffo/cli",
3
- "version": "0.199.9",
3
+ "version": "0.200.0",
4
4
  "description": "Biffo project scaffolding CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",