cspell-glob 5.16.0 → 5.18.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/GlobMatcher.d.ts +5 -0
- package/dist/GlobMatcher.js +13 -2
- package/dist/globHelper.d.ts +17 -1
- package/dist/globHelper.js +16 -5
- package/package.json +3 -3
package/dist/GlobMatcher.d.ts
CHANGED
|
@@ -26,6 +26,11 @@ interface NormalizedGlobMatchOptions {
|
|
|
26
26
|
* @default: process.cwd()
|
|
27
27
|
*/
|
|
28
28
|
root: string;
|
|
29
|
+
/**
|
|
30
|
+
* The directory to use as the current working directory.
|
|
31
|
+
* @default: process.cwd();
|
|
32
|
+
*/
|
|
33
|
+
cwd: string;
|
|
29
34
|
/**
|
|
30
35
|
* Allows matching against directories with a leading `.`.
|
|
31
36
|
*
|
package/dist/GlobMatcher.js
CHANGED
|
@@ -31,9 +31,9 @@ class GlobMatcher {
|
|
|
31
31
|
const { mode = 'exclude' } = options;
|
|
32
32
|
const isExcludeMode = mode !== 'include';
|
|
33
33
|
_nodePath = (_a = options.nodePath) !== null && _a !== void 0 ? _a : _nodePath;
|
|
34
|
-
const { root = _nodePath.resolve(), dot = isExcludeMode, nodePath = _nodePath, nested = isExcludeMode, nobrace, } = options;
|
|
34
|
+
const { root = _nodePath.resolve(), dot = isExcludeMode, nodePath = _nodePath, nested = isExcludeMode, cwd = process.cwd(), nobrace, } = clean(options);
|
|
35
35
|
const normalizedRoot = nodePath.resolve(nodePath.normalize(root));
|
|
36
|
-
this.options = { root: normalizedRoot, dot, nodePath, nested, mode, nobrace };
|
|
36
|
+
this.options = { root: normalizedRoot, dot, nodePath, nested, mode, nobrace, cwd };
|
|
37
37
|
patterns = Array.isArray(patterns)
|
|
38
38
|
? patterns
|
|
39
39
|
: typeof patterns === 'string'
|
|
@@ -122,4 +122,15 @@ function buildMatcherFn(patterns, options) {
|
|
|
122
122
|
};
|
|
123
123
|
return fn;
|
|
124
124
|
}
|
|
125
|
+
function clean(obj) {
|
|
126
|
+
if (typeof obj !== 'object')
|
|
127
|
+
return obj;
|
|
128
|
+
const r = obj;
|
|
129
|
+
for (const key of Object.keys(r)) {
|
|
130
|
+
if (r[key] === undefined) {
|
|
131
|
+
delete r[key];
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return obj;
|
|
135
|
+
}
|
|
125
136
|
//# sourceMappingURL=GlobMatcher.js.map
|
package/dist/globHelper.d.ts
CHANGED
|
@@ -16,9 +16,24 @@ export declare function isGlobPatternWithOptionalRoot(g: GlobPattern): g is Glob
|
|
|
16
16
|
export declare function isGlobPatternWithRoot(g: GlobPatternWithRoot | GlobPatternWithOptionalRoot): g is GlobPatternWithRoot;
|
|
17
17
|
export declare function isGlobPatternNormalized(g: GlobPattern | GlobPatternNormalized): g is GlobPatternNormalized;
|
|
18
18
|
export interface NormalizeOptions {
|
|
19
|
+
/**
|
|
20
|
+
* Indicates that the glob should be modified to match nested patterns.
|
|
21
|
+
*
|
|
22
|
+
* Example: `node_modules` becomes `**/node_modules/**`, `**/node_modules`, and `node_modules/**`
|
|
23
|
+
*/
|
|
19
24
|
nested: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* This is the root to use for the glob if the glob does not already contain one.
|
|
27
|
+
*/
|
|
20
28
|
root: string;
|
|
21
|
-
|
|
29
|
+
/**
|
|
30
|
+
* This is the replacement for `${cwd}` in either the root or in the glob.
|
|
31
|
+
*/
|
|
32
|
+
cwd?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Optional path interface for working with paths.
|
|
35
|
+
*/
|
|
36
|
+
nodePath?: PathInterface;
|
|
22
37
|
}
|
|
23
38
|
/**
|
|
24
39
|
*
|
|
@@ -26,6 +41,7 @@ export interface NormalizeOptions {
|
|
|
26
41
|
* @param options - Normalization options.
|
|
27
42
|
*/
|
|
28
43
|
export declare function normalizeGlobPatterns(patterns: GlobPattern[], options: NormalizeOptions): GlobPatternNormalized[];
|
|
44
|
+
export declare function normalizeGlobPattern(g: GlobPattern, options: NormalizeOptions): GlobPatternNormalized[];
|
|
29
45
|
/**
|
|
30
46
|
* Try to adjust the root of a glob to match a new root. If it is not possible, the original glob is returned.
|
|
31
47
|
* Note: this does NOT generate absolutely correct glob patterns. The results are intended to be used as a
|
package/dist/globHelper.js
CHANGED
|
@@ -19,7 +19,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.__testing__ = exports.normalizeGlobToRoot = exports.normalizeGlobPatterns = exports.isGlobPatternNormalized = exports.isGlobPatternWithRoot = exports.isGlobPatternWithOptionalRoot = exports.doesRootContainPath = exports.fileOrGlobToGlob = void 0;
|
|
22
|
+
exports.__testing__ = exports.normalizeGlobToRoot = exports.normalizeGlobPattern = exports.normalizeGlobPatterns = exports.isGlobPatternNormalized = exports.isGlobPatternWithRoot = exports.isGlobPatternWithOptionalRoot = exports.doesRootContainPath = exports.fileOrGlobToGlob = void 0;
|
|
23
|
+
/* eslint-disable no-irregular-whitespace */
|
|
23
24
|
const Path = __importStar(require("path"));
|
|
24
25
|
const { posix } = Path;
|
|
25
26
|
const relRegExp = /^\.[\\/]/;
|
|
@@ -78,6 +79,11 @@ function isGlobPatternNormalized(g) {
|
|
|
78
79
|
return 'rawGlob' in gr && 'rawRoot' in gr && typeof gr.rawGlob === 'string';
|
|
79
80
|
}
|
|
80
81
|
exports.isGlobPatternNormalized = isGlobPatternNormalized;
|
|
82
|
+
/**
|
|
83
|
+
* @param pattern glob pattern
|
|
84
|
+
* @param nested when true add `**/<glob>/**`
|
|
85
|
+
* @returns the set of matching globs.
|
|
86
|
+
*/
|
|
81
87
|
function normalizePattern(pattern, nested) {
|
|
82
88
|
pattern = pattern.replace(/^(!!)+/, '');
|
|
83
89
|
const isNeg = pattern.startsWith('!');
|
|
@@ -121,27 +127,32 @@ function normalizeGlobPatterns(patterns, options) {
|
|
|
121
127
|
yield glob;
|
|
122
128
|
continue;
|
|
123
129
|
}
|
|
124
|
-
yield*
|
|
130
|
+
yield* normalizeGlobPattern(glob, options);
|
|
125
131
|
}
|
|
126
132
|
}
|
|
127
133
|
return [...normalize()];
|
|
128
134
|
}
|
|
129
135
|
exports.normalizeGlobPatterns = normalizeGlobPatterns;
|
|
130
|
-
function
|
|
136
|
+
function normalizeGlobPattern(g, options) {
|
|
131
137
|
var _a;
|
|
132
|
-
const { root, nodePath: path, nested } = options;
|
|
138
|
+
const { root, nodePath: path = Path, nested, cwd = Path.resolve() } = options;
|
|
133
139
|
g = !isGlobPatternWithOptionalRoot(g) ? { glob: g } : g;
|
|
134
140
|
const gr = { ...g, root: (_a = g.root) !== null && _a !== void 0 ? _a : root };
|
|
135
141
|
const rawRoot = gr.root;
|
|
136
142
|
const rawGlob = g.glob;
|
|
137
143
|
gr.glob = gr.glob.trim(); // trimGlob(g.glob);
|
|
144
|
+
if (gr.glob.startsWith('${cwd}')) {
|
|
145
|
+
gr.glob = gr.glob.replace('${cwd}', '');
|
|
146
|
+
gr.root = '${cwd}';
|
|
147
|
+
}
|
|
138
148
|
if (gr.root.startsWith('${cwd}')) {
|
|
139
|
-
gr.root = path.
|
|
149
|
+
gr.root = path.resolve(gr.root.replace('${cwd}', cwd));
|
|
140
150
|
}
|
|
141
151
|
gr.root = path.resolve(root, path.normalize(gr.root));
|
|
142
152
|
const globs = normalizePattern(gr.glob, nested);
|
|
143
153
|
return globs.map((glob) => ({ ...gr, glob, rawGlob, rawRoot }));
|
|
144
154
|
}
|
|
155
|
+
exports.normalizeGlobPattern = normalizeGlobPattern;
|
|
145
156
|
/**
|
|
146
157
|
* Try to adjust the root of a glob to match a new root. If it is not possible, the original glob is returned.
|
|
147
158
|
* Note: this does NOT generate absolutely correct glob patterns. The results are intended to be used as a
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cspell-glob",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.18.0",
|
|
4
4
|
"description": "Glob matcher for cspell",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cspell",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/micromatch": "^4.0.2",
|
|
49
|
-
"@types/node": "^17.0.
|
|
49
|
+
"@types/node": "^17.0.13",
|
|
50
50
|
"jest": "^27.4.7",
|
|
51
51
|
"rimraf": "^3.0.2"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "ef4c46dfb6f2938724afb5332ea2fdf9b67d99e4"
|
|
54
54
|
}
|