cspell-glob 10.4.0-alpha.1 → 10.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/dist/index.d.ts CHANGED
@@ -69,10 +69,10 @@ interface GlobPatternNormalized extends GlobPatternWithRoot {
69
69
  * @param root - absolute path to the directory that will be considered the root when testing the glob pattern.
70
70
  * @param path - optional node path methods - used for testing
71
71
  */
72
- declare function fileOrGlobToGlob(fileOrGlob: string | GlobPattern, root: string, path?: PathInterface): GlobPatternWithRoot;
73
- declare function isGlobPatternWithOptionalRoot(g: GlobPattern): g is GlobPatternWithOptionalRoot;
74
- declare function isGlobPatternWithRoot(g: GlobPattern): g is GlobPatternWithRoot;
75
- declare function isGlobPatternNormalized(g: GlobPattern | GlobPatternNormalized): g is GlobPatternNormalized;
72
+ export declare function fileOrGlobToGlob(fileOrGlob: string | GlobPattern, root: string, path?: PathInterface): GlobPatternWithRoot;
73
+ export declare function isGlobPatternWithOptionalRoot(g: GlobPattern): g is GlobPatternWithOptionalRoot;
74
+ export declare function isGlobPatternWithRoot(g: GlobPattern): g is GlobPatternWithRoot;
75
+ export declare function isGlobPatternNormalized(g: GlobPattern | GlobPatternNormalized): g is GlobPatternNormalized;
76
76
  interface NormalizeOptions {
77
77
  /**
78
78
  * Indicates that the glob should be modified to match nested patterns.
@@ -98,8 +98,8 @@ interface NormalizeOptions {
98
98
  * @param patterns - glob patterns to normalize.
99
99
  * @param options - Normalization options.
100
100
  */
101
- declare function normalizeGlobPatterns(patterns: GlobPattern[], options: NormalizeOptions): GlobPatternNormalized[];
102
- declare function workaroundPicomatchBug(glob: string): string;
101
+ export declare function normalizeGlobPatterns(patterns: GlobPattern[], options: NormalizeOptions): GlobPatternNormalized[];
102
+ export declare function workaroundPicomatchBug(glob: string): string;
103
103
  //#endregion
104
104
  //#region src/GlobMatcher.d.ts
105
105
  type Optional<T> = { [P in keyof T]?: T[P] | undefined; };
@@ -157,7 +157,7 @@ interface NormalizedGlobMatchOptions {
157
157
  */
158
158
  nobrace?: boolean | undefined;
159
159
  }
160
- declare class GlobMatcher {
160
+ export declare class GlobMatcher {
161
161
  /**
162
162
  * @param filename full path of file to match against.
163
163
  * @returns a GlobMatch - information about the match.
@@ -199,5 +199,5 @@ declare class GlobMatcher {
199
199
  match(filename: string): boolean;
200
200
  }
201
201
  //#endregion
202
- export { type GlobMatch, type GlobMatchNoRule, type GlobMatchOptions, type GlobMatchRule, GlobMatcher, type GlobPattern, type GlobPatternNormalized, type GlobPatternWithOptionalRoot, type GlobPatternWithRoot, type NormalizeOptions, type PathInterface, type SimpleGlobPattern, fileOrGlobToGlob, isGlobPatternNormalized, isGlobPatternWithOptionalRoot, isGlobPatternWithRoot, normalizeGlobPatterns, workaroundPicomatchBug };
202
+ export type { GlobMatch, GlobMatchNoRule, GlobMatchOptions, GlobMatchRule, GlobPattern, GlobPatternNormalized, GlobPatternWithOptionalRoot, GlobPatternWithRoot, NormalizeOptions, PathInterface, SimpleGlobPattern };
203
203
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -449,7 +449,7 @@ var GlobMatcher = class {
449
449
  this.patterns = globPatterns;
450
450
  this.root = normalizedRoot;
451
451
  this.dot = dot;
452
- this.matchEx = buildMatcherFn(this.id, this.patterns, this.options);
452
+ this.matchEx = buildMatcherFn(this.id, globPatterns, this.options);
453
453
  }
454
454
  /**
455
455
  * Check to see if a filename matches any of the globs.
@@ -503,8 +503,6 @@ function buildMatcherFn(_id, patterns, options) {
503
503
  reg
504
504
  };
505
505
  });
506
- const negRules = rules.filter((r) => r.isNeg);
507
- const posRules = rules.filter((r) => !r.isNeg);
508
506
  const mapRoots = /* @__PURE__ */ new Map();
509
507
  const fn = (filename) => {
510
508
  const fileUrl = builder.toFileURL(filename);
@@ -525,7 +523,9 @@ function buildMatcherFn(_id, patterns, options) {
525
523
  }
526
524
  return lastRel;
527
525
  }
528
- function testRules(rules, matched) {
526
+ function testRules() {
527
+ let result;
528
+ let lastMatchedPattern;
529
529
  for (const rule of rules) {
530
530
  const pattern = rule.pattern;
531
531
  const root = pattern.root;
@@ -542,17 +542,21 @@ function buildMatcherFn(_id, patterns, options) {
542
542
  const relPathToFile = relativeToRoot(rootURL);
543
543
  isMatch = isRelativeValueNested(relPathToFile) && rule.fn(relPathToFile);
544
544
  }
545
- if (isMatch) return {
546
- matched,
547
- glob: pattern.glob,
548
- root,
549
- pattern,
550
- index: rule.index,
551
- isNeg: rule.isNeg
552
- };
545
+ if (isMatch && (pattern.rawRoot !== lastMatchedPattern?.rawRoot || pattern.rawGlob !== lastMatchedPattern?.rawGlob)) {
546
+ result = {
547
+ matched: !rule.isNeg,
548
+ glob: pattern.glob,
549
+ root,
550
+ pattern,
551
+ index: rule.index,
552
+ isNeg: rule.isNeg
553
+ };
554
+ lastMatchedPattern = pattern;
555
+ }
553
556
  }
557
+ return result;
554
558
  }
555
- return testRules(negRules, false) || testRules(posRules, true) || { matched: false };
559
+ return testRules() || { matched: false };
556
560
  };
557
561
  return fn;
558
562
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cspell-glob",
3
- "version": "10.4.0-alpha.1",
3
+ "version": "10.4.0",
4
4
  "description": "Glob matcher for cspell",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -55,7 +55,7 @@
55
55
  "watch": "tsdown -w"
56
56
  },
57
57
  "dependencies": {
58
- "@cspell/url": "10.4.0-alpha.1",
58
+ "@cspell/url": "10.4.0",
59
59
  "picomatch": "^4.0.7"
60
60
  },
61
61
  "devDependencies": {
@@ -66,5 +66,5 @@
66
66
  "engines": {
67
67
  "node": ">=22.18.0"
68
68
  },
69
- "gitHead": "628768a6e62b792e628189b41e63e12e5d3d8fe3"
69
+ "gitHead": "7e2bbb5e866c827ac5d2cf6b84bf3e1a016d0823"
70
70
  }