@alchemy.run/node-utils 0.0.0 → 0.0.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.
@@ -0,0 +1,40 @@
1
+ declare const isPathValid: (path: any) => any;
2
+ declare const _default: (options?: IgnoreOptions) => IgnoreInstance;
3
+ export default _default;
4
+ export { isPathValid };
5
+ type Pathname = string;
6
+ interface PatternParams {
7
+ pattern: string;
8
+ mark?: string;
9
+ }
10
+ export interface IgnoreOptions {
11
+ ignorecase?: boolean;
12
+ /** For compatibility. */
13
+ ignoreCase?: boolean;
14
+ allowRelativePaths?: boolean;
15
+ }
16
+ export interface IgnoreInstance {
17
+ add(patterns: string | IgnoreInstance | readonly (string | IgnoreInstance)[] | PatternParams): this;
18
+ filter(pathnames: readonly Pathname[]): Pathname[];
19
+ createFilter(): (pathname: Pathname) => boolean;
20
+ ignores(pathname: Pathname): boolean;
21
+ test(pathname: Pathname): {
22
+ ignored: boolean;
23
+ unignored: boolean;
24
+ rule?: {
25
+ pattern: string;
26
+ mark?: string;
27
+ negative: boolean;
28
+ };
29
+ };
30
+ checkIgnore(pathname: Pathname): {
31
+ ignored: boolean;
32
+ unignored: boolean;
33
+ rule?: {
34
+ pattern: string;
35
+ mark?: string;
36
+ negative: boolean;
37
+ };
38
+ };
39
+ }
40
+ //# sourceMappingURL=ignore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ignore.d.ts","sourceRoot":"","sources":["../src/ignore.ts"],"names":[],"mappings":"AAguBA,QAAA,MAAM,WAAW,GAAI,SAAI,QACuC,CAAC;wBAkC5B,CACnC,OAAO,CAAC,EAAE,aAAa,KACpB,cAAc;AAFnB,wBAEoB;AACpB,OAAO,EAAE,WAAW,EAAE,CAAC;AAKvB,KAAK,QAAQ,GAAG,MAAM,CAAC;AAEvB,UAAU,aAAa;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,yBAAyB;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,MAAM,WAAW,cAAc;IAC7B,GAAG,CACD,QAAQ,EACJ,MAAM,GACN,cAAc,GACd,SAAS,CAAC,MAAM,GAAG,cAAc,CAAC,EAAE,GACpC,aAAa,GAChB,IAAI,CAAC;IACR,MAAM,CAAC,SAAS,EAAE,SAAS,QAAQ,EAAE,GAAG,QAAQ,EAAE,CAAC;IACnD,YAAY,IAAI,CAAC,QAAQ,EAAE,QAAQ,KAAK,OAAO,CAAC;IAChD,OAAO,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC;IACrC,IAAI,CAAC,QAAQ,EAAE,QAAQ,GAAG;QACxB,OAAO,EAAE,OAAO,CAAC;QACjB,SAAS,EAAE,OAAO,CAAC;QACnB,IAAI,CAAC,EAAE;YAAE,OAAO,EAAE,MAAM,CAAC;YAAC,IAAI,CAAC,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,OAAO,CAAA;SAAE,CAAC;KAC9D,CAAC;IACF,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG;QAC/B,OAAO,EAAE,OAAO,CAAC;QACjB,SAAS,EAAE,OAAO,CAAC;QACnB,IAAI,CAAC,EAAE;YAAE,OAAO,EAAE,MAAM,CAAC;YAAC,IAAI,CAAC,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,OAAO,CAAA;SAAE,CAAC;KAC9D,CAAC;CACH"}
package/lib/ignore.js ADDED
@@ -0,0 +1,591 @@
1
+ // @ts-nocheck
2
+ /*
3
+ * Vendored copy of `ignore` (https://github.com/kaelzhang/node-ignore)
4
+ * Version: 7.0.5
5
+ *
6
+ * The body below is a mechanical copy of upstream `index.js`. The only
7
+ * substantive change is the CommonJS export footer, which has been rewritten
8
+ * as ES module exports; the upstream `index.d.ts` declarations are appended.
9
+ *
10
+ * ---------------------------------------------------------------------------
11
+ * Copyright (c) 2013 Kael Zhang <i@kael.me>, contributors
12
+ * http://kael.me/
13
+ *
14
+ * Permission is hereby granted, free of charge, to any person obtaining
15
+ * a copy of this software and associated documentation files (the
16
+ * "Software"), to deal in the Software without restriction, including
17
+ * without limitation the rights to use, copy, modify, merge, publish,
18
+ * distribute, sublicense, and/or sell copies of the Software, and to
19
+ * permit persons to whom the Software is furnished to do so, subject to
20
+ * the following conditions:
21
+ *
22
+ * The above copyright notice and this permission notice shall be
23
+ * included in all copies or substantial portions of the Software.
24
+ *
25
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32
+ * ---------------------------------------------------------------------------
33
+ */
34
+ // A simple implementation of make-array
35
+ function makeArray(subject) {
36
+ return Array.isArray(subject) ? subject : [subject];
37
+ }
38
+ const UNDEFINED = undefined;
39
+ const EMPTY = "";
40
+ const SPACE = " ";
41
+ const ESCAPE = "\\";
42
+ const REGEX_TEST_BLANK_LINE = /^\s+$/;
43
+ const REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/;
44
+ const REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
45
+ const REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
46
+ const REGEX_SPLITALL_CRLF = /\r?\n/g;
47
+ // Invalid:
48
+ // - /foo,
49
+ // - ./foo,
50
+ // - ../foo,
51
+ // - .
52
+ // - ..
53
+ // Valid:
54
+ // - .foo
55
+ const REGEX_TEST_INVALID_PATH = /^\.{0,2}\/|^\.{1,2}$/;
56
+ const REGEX_TEST_TRAILING_SLASH = /\/$/;
57
+ const SLASH = "/";
58
+ // Do not use ternary expression here, since "istanbul ignore next" is buggy
59
+ let TMP_KEY_IGNORE = "node-ignore";
60
+ /* istanbul ignore else */
61
+ if (typeof Symbol !== "undefined") {
62
+ TMP_KEY_IGNORE = Symbol.for("node-ignore");
63
+ }
64
+ const KEY_IGNORE = TMP_KEY_IGNORE;
65
+ const define = (object, key, value) => {
66
+ Object.defineProperty(object, key, { value });
67
+ return value;
68
+ };
69
+ const REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
70
+ const RETURN_FALSE = () => false;
71
+ // Sanitize the range of a regular expression
72
+ // The cases are complicated, see test cases for details
73
+ const sanitizeRange = (range) => range.replace(REGEX_REGEXP_RANGE, (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0)
74
+ ? match
75
+ : // Invalid range (out of order) which is ok for gitignore rules but
76
+ // fatal for JavaScript regular expression, so eliminate it.
77
+ EMPTY);
78
+ // See fixtures #59
79
+ const cleanRangeBackSlash = (slashes) => {
80
+ const { length } = slashes;
81
+ return slashes.slice(0, length - (length % 2));
82
+ };
83
+ // > If the pattern ends with a slash,
84
+ // > it is removed for the purpose of the following description,
85
+ // > but it would only find a match with a directory.
86
+ // > In other words, foo/ will match a directory foo and paths underneath it,
87
+ // > but will not match a regular file or a symbolic link foo
88
+ // > (this is consistent with the way how pathspec works in general in Git).
89
+ // '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`'
90
+ // -> ignore-rules will not deal with it, because it costs extra `fs.stat` call
91
+ // you could use option `mark: true` with `glob`
92
+ // '`foo/`' should not continue with the '`..`'
93
+ const REPLACERS = [
94
+ [
95
+ // Remove BOM
96
+ // TODO:
97
+ // Other similar zero-width characters?
98
+ /^\uFEFF/,
99
+ () => EMPTY,
100
+ ],
101
+ // > Trailing spaces are ignored unless they are quoted with backslash ("\")
102
+ [
103
+ // (a\ ) -> (a )
104
+ // (a ) -> (a)
105
+ // (a ) -> (a)
106
+ // (a \ ) -> (a )
107
+ /((?:\\\\)*?)(\\?\s+)$/,
108
+ (_, m1, m2) => m1 + (m2.indexOf("\\") === 0 ? SPACE : EMPTY),
109
+ ],
110
+ // Replace (\ ) with ' '
111
+ // (\ ) -> ' '
112
+ // (\\ ) -> '\\ '
113
+ // (\\\ ) -> '\\ '
114
+ [
115
+ /(\\+?)\s/g,
116
+ (_, m1) => {
117
+ const { length } = m1;
118
+ return m1.slice(0, length - (length % 2)) + SPACE;
119
+ },
120
+ ],
121
+ // Escape metacharacters
122
+ // which is written down by users but means special for regular expressions.
123
+ // > There are 12 characters with special meanings:
124
+ // > - the backslash \,
125
+ // > - the caret ^,
126
+ // > - the dollar sign $,
127
+ // > - the period or dot .,
128
+ // > - the vertical bar or pipe symbol |,
129
+ // > - the question mark ?,
130
+ // > - the asterisk or star *,
131
+ // > - the plus sign +,
132
+ // > - the opening parenthesis (,
133
+ // > - the closing parenthesis ),
134
+ // > - and the opening square bracket [,
135
+ // > - the opening curly brace {,
136
+ // > These special characters are often called "metacharacters".
137
+ [/[\\$.|*+(){^]/g, (match) => `\\${match}`],
138
+ [
139
+ // > a question mark (?) matches a single character
140
+ /(?!\\)\?/g,
141
+ () => "[^/]",
142
+ ],
143
+ // leading slash
144
+ [
145
+ // > A leading slash matches the beginning of the pathname.
146
+ // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
147
+ // A leading slash matches the beginning of the pathname
148
+ /^\//,
149
+ () => "^",
150
+ ],
151
+ // replace special metacharacter slash after the leading slash
152
+ [/\//g, () => "\\/"],
153
+ [
154
+ // > A leading "**" followed by a slash means match in all directories.
155
+ // > For example, "**/foo" matches file or directory "foo" anywhere,
156
+ // > the same as pattern "foo".
157
+ // > "**/foo/bar" matches file or directory "bar" anywhere that is directly
158
+ // > under directory "foo".
159
+ // Notice that the '*'s have been replaced as '\\*'
160
+ /^\^*\\\*\\\*\\\//,
161
+ // '**/foo' <-> 'foo'
162
+ () => "^(?:.*\\/)?",
163
+ ],
164
+ // starting
165
+ [
166
+ // there will be no leading '/'
167
+ // (which has been replaced by section "leading slash")
168
+ // If starts with '**', adding a '^' to the regular expression also works
169
+ /^(?=[^^])/,
170
+ function startingReplacer() {
171
+ // If has a slash `/` at the beginning or middle
172
+ return !/\/(?!$)/.test(this)
173
+ ? // > Prior to 2.22.1
174
+ // > If the pattern does not contain a slash /,
175
+ // > Git treats it as a shell glob pattern
176
+ // Actually, if there is only a trailing slash,
177
+ // git also treats it as a shell glob pattern
178
+ // After 2.22.1 (compatible but clearer)
179
+ // > If there is a separator at the beginning or middle (or both)
180
+ // > of the pattern, then the pattern is relative to the directory
181
+ // > level of the particular .gitignore file itself.
182
+ // > Otherwise the pattern may also match at any level below
183
+ // > the .gitignore level.
184
+ "(?:^|\\/)"
185
+ : // > Otherwise, Git treats the pattern as a shell glob suitable for
186
+ // > consumption by fnmatch(3)
187
+ "^";
188
+ },
189
+ ],
190
+ // two globstars
191
+ [
192
+ // Use lookahead assertions so that we could match more than one `'/**'`
193
+ /\\\/\\\*\\\*(?=\\\/|$)/g,
194
+ // Zero, one or several directories
195
+ // should not use '*', or it will be replaced by the next replacer
196
+ // Check if it is not the last `'/**'`
197
+ (_, index, str) => index + 6 < str.length
198
+ ? // case: /**/
199
+ // > A slash followed by two consecutive asterisks then a slash matches
200
+ // > zero or more directories.
201
+ // > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.
202
+ // '/**/'
203
+ "(?:\\/[^\\/]+)*"
204
+ : // case: /**
205
+ // > A trailing `"/**"` matches everything inside.
206
+ // #21: everything inside but it should not include the current folder
207
+ "\\/.+",
208
+ ],
209
+ // normal intermediate wildcards
210
+ [
211
+ // Never replace escaped '*'
212
+ // ignore rule '\*' will match the path '*'
213
+ // 'abc.*/' -> go
214
+ // 'abc.*' -> skip this rule,
215
+ // coz trailing single wildcard will be handed by [trailing wildcard]
216
+ /(^|[^\\]+)(\\\*)+(?=.+)/g,
217
+ // '*.js' matches '.js'
218
+ // '*.js' doesn't match 'abc'
219
+ (_, p1, p2) => {
220
+ // 1.
221
+ // > An asterisk "*" matches anything except a slash.
222
+ // 2.
223
+ // > Other consecutive asterisks are considered regular asterisks
224
+ // > and will match according to the previous rules.
225
+ const unescaped = p2.replace(/\\\*/g, "[^\\/]*");
226
+ return p1 + unescaped;
227
+ },
228
+ ],
229
+ [
230
+ // unescape, revert step 3 except for back slash
231
+ // For example, if a user escape a '\\*',
232
+ // after step 3, the result will be '\\\\\\*'
233
+ /\\\\\\(?=[$.|*+(){^])/g,
234
+ () => ESCAPE,
235
+ ],
236
+ [
237
+ // '\\\\' -> '\\'
238
+ /\\\\/g,
239
+ () => ESCAPE,
240
+ ],
241
+ [
242
+ // > The range notation, e.g. [a-zA-Z],
243
+ // > can be used to match one of the characters in a range.
244
+ // `\` is escaped by step 3
245
+ /(\\)?\[([^\]/]*?)(\\*)($|\])/g,
246
+ (match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE
247
+ ? // '\\[bar]' -> '\\\\[bar\\]'
248
+ `\\[${range}${cleanRangeBackSlash(endEscape)}${close}`
249
+ : close === "]"
250
+ ? endEscape.length % 2 === 0
251
+ ? // A normal case, and it is a range notation
252
+ // '[bar]'
253
+ // '[bar\\\\]'
254
+ `[${sanitizeRange(range)}${endEscape}]`
255
+ : // Invalid range notaton
256
+ // '[bar\\]' -> '[bar\\\\]'
257
+ "[]"
258
+ : "[]",
259
+ ],
260
+ // ending
261
+ [
262
+ // 'js' will not match 'js.'
263
+ // 'ab' will not match 'abc'
264
+ /(?:[^*])$/,
265
+ // WTF!
266
+ // https://git-scm.com/docs/gitignore
267
+ // changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1)
268
+ // which re-fixes #24, #38
269
+ // > If there is a separator at the end of the pattern then the pattern
270
+ // > will only match directories, otherwise the pattern can match both
271
+ // > files and directories.
272
+ // 'js*' will not match 'a.js'
273
+ // 'js/' will not match 'a.js'
274
+ // 'js' will match 'a.js' and 'a.js/'
275
+ (match) => /\/$/.test(match)
276
+ ? // foo/ will not match 'foo'
277
+ `${match}$`
278
+ : // foo matches 'foo' and 'foo/'
279
+ `${match}(?=$|\\/$)`,
280
+ ],
281
+ ];
282
+ const REGEX_REPLACE_TRAILING_WILDCARD = /(^|\\\/)?\\\*$/;
283
+ const MODE_IGNORE = "regex";
284
+ const MODE_CHECK_IGNORE = "checkRegex";
285
+ const UNDERSCORE = "_";
286
+ const TRAILING_WILD_CARD_REPLACERS = {
287
+ [MODE_IGNORE](_, p1) {
288
+ const prefix = p1
289
+ ? // '\^':
290
+ // '/*' does not match EMPTY
291
+ // '/*' does not match everything
292
+ // '\\\/':
293
+ // 'abc/*' does not match 'abc/'
294
+ `${p1}[^/]+`
295
+ : // 'a*' matches 'a'
296
+ // 'a*' matches 'aa'
297
+ "[^/]*";
298
+ return `${prefix}(?=$|\\/$)`;
299
+ },
300
+ [MODE_CHECK_IGNORE](_, p1) {
301
+ // When doing `git check-ignore`
302
+ const prefix = p1
303
+ ? // '\\\/':
304
+ // 'abc/*' DOES match 'abc/' !
305
+ `${p1}[^/]*`
306
+ : // 'a*' matches 'a'
307
+ // 'a*' matches 'aa'
308
+ "[^/]*";
309
+ return `${prefix}(?=$|\\/$)`;
310
+ },
311
+ };
312
+ // @param {pattern}
313
+ const makeRegexPrefix = (pattern) => REPLACERS.reduce((prev, [matcher, replacer]) => prev.replace(matcher, replacer.bind(pattern)), pattern);
314
+ const isString = (subject) => typeof subject === "string";
315
+ // > A blank line matches no files, so it can serve as a separator for readability.
316
+ const checkPattern = (pattern) => pattern &&
317
+ isString(pattern) &&
318
+ !REGEX_TEST_BLANK_LINE.test(pattern) &&
319
+ !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern) &&
320
+ // > A line starting with # serves as a comment.
321
+ pattern.indexOf("#") !== 0;
322
+ const splitPattern = (pattern) => pattern.split(REGEX_SPLITALL_CRLF).filter(Boolean);
323
+ class IgnoreRule {
324
+ constructor(pattern, mark, body, ignoreCase, negative, prefix) {
325
+ this.pattern = pattern;
326
+ this.mark = mark;
327
+ this.negative = negative;
328
+ define(this, "body", body);
329
+ define(this, "ignoreCase", ignoreCase);
330
+ define(this, "regexPrefix", prefix);
331
+ }
332
+ get regex() {
333
+ const key = UNDERSCORE + MODE_IGNORE;
334
+ if (this[key]) {
335
+ return this[key];
336
+ }
337
+ return this._make(MODE_IGNORE, key);
338
+ }
339
+ get checkRegex() {
340
+ const key = UNDERSCORE + MODE_CHECK_IGNORE;
341
+ if (this[key]) {
342
+ return this[key];
343
+ }
344
+ return this._make(MODE_CHECK_IGNORE, key);
345
+ }
346
+ _make(mode, key) {
347
+ const str = this.regexPrefix.replace(REGEX_REPLACE_TRAILING_WILDCARD,
348
+ // It does not need to bind pattern
349
+ TRAILING_WILD_CARD_REPLACERS[mode]);
350
+ const regex = this.ignoreCase ? new RegExp(str, "i") : new RegExp(str);
351
+ return define(this, key, regex);
352
+ }
353
+ }
354
+ const createRule = ({ pattern, mark }, ignoreCase) => {
355
+ let negative = false;
356
+ let body = pattern;
357
+ // > An optional prefix "!" which negates the pattern;
358
+ if (body.indexOf("!") === 0) {
359
+ negative = true;
360
+ body = body.substr(1);
361
+ }
362
+ body = body
363
+ // > Put a backslash ("\") in front of the first "!" for patterns that
364
+ // > begin with a literal "!", for example, `"\!important!.txt"`.
365
+ .replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, "!")
366
+ // > Put a backslash ("\") in front of the first hash for patterns that
367
+ // > begin with a hash.
368
+ .replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, "#");
369
+ const regexPrefix = makeRegexPrefix(body);
370
+ return new IgnoreRule(pattern, mark, body, ignoreCase, negative, regexPrefix);
371
+ };
372
+ class RuleManager {
373
+ constructor(ignoreCase) {
374
+ this._ignoreCase = ignoreCase;
375
+ this._rules = [];
376
+ }
377
+ _add(pattern) {
378
+ // #32
379
+ if (pattern && pattern[KEY_IGNORE]) {
380
+ this._rules = this._rules.concat(pattern._rules._rules);
381
+ this._added = true;
382
+ return;
383
+ }
384
+ if (isString(pattern)) {
385
+ pattern = {
386
+ pattern,
387
+ };
388
+ }
389
+ if (checkPattern(pattern.pattern)) {
390
+ const rule = createRule(pattern, this._ignoreCase);
391
+ this._added = true;
392
+ this._rules.push(rule);
393
+ }
394
+ }
395
+ // @param {Array<string> | string | Ignore} pattern
396
+ add(pattern) {
397
+ this._added = false;
398
+ makeArray(isString(pattern) ? splitPattern(pattern) : pattern).forEach(this._add, this);
399
+ return this._added;
400
+ }
401
+ // Test one single path without recursively checking parent directories
402
+ //
403
+ // - checkUnignored `boolean` whether should check if the path is unignored,
404
+ // setting `checkUnignored` to `false` could reduce additional
405
+ // path matching.
406
+ // - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
407
+ // @returns {TestResult} true if a file is ignored
408
+ test(path, checkUnignored, mode) {
409
+ let ignored = false;
410
+ let unignored = false;
411
+ let matchedRule;
412
+ this._rules.forEach((rule) => {
413
+ const { negative } = rule;
414
+ // | ignored : unignored
415
+ // -------- | ---------------------------------------
416
+ // negative | 0:0 | 0:1 | 1:0 | 1:1
417
+ // -------- | ------- | ------- | ------- | --------
418
+ // 0 | TEST | TEST | SKIP | X
419
+ // 1 | TESTIF | SKIP | TEST | X
420
+ // - SKIP: always skip
421
+ // - TEST: always test
422
+ // - TESTIF: only test if checkUnignored
423
+ // - X: that never happen
424
+ if ((unignored === negative && ignored !== unignored) ||
425
+ (negative && !ignored && !unignored && !checkUnignored)) {
426
+ return;
427
+ }
428
+ const matched = rule[mode].test(path);
429
+ if (!matched) {
430
+ return;
431
+ }
432
+ ignored = !negative;
433
+ unignored = negative;
434
+ matchedRule = negative ? UNDEFINED : rule;
435
+ });
436
+ const ret = {
437
+ ignored,
438
+ unignored,
439
+ };
440
+ if (matchedRule) {
441
+ ret.rule = matchedRule;
442
+ }
443
+ return ret;
444
+ }
445
+ }
446
+ const throwError = (message, Ctor) => {
447
+ throw new Ctor(message);
448
+ };
449
+ const checkPath = (path, originalPath, doThrow) => {
450
+ if (!isString(path)) {
451
+ return doThrow(`path must be a string, but got \`${originalPath}\``, TypeError);
452
+ }
453
+ // We don't know if we should ignore EMPTY, so throw
454
+ if (!path) {
455
+ return doThrow(`path must not be empty`, TypeError);
456
+ }
457
+ // Check if it is a relative path
458
+ if (checkPath.isNotRelative(path)) {
459
+ const r = "`path.relative()`d";
460
+ return doThrow(`path should be a ${r} string, but got "${originalPath}"`, RangeError);
461
+ }
462
+ return true;
463
+ };
464
+ const isNotRelative = (path) => REGEX_TEST_INVALID_PATH.test(path);
465
+ checkPath.isNotRelative = isNotRelative;
466
+ // On windows, the following function will be replaced
467
+ /* istanbul ignore next */
468
+ checkPath.convert = (p) => p;
469
+ class Ignore {
470
+ constructor({ ignorecase = true, ignoreCase = ignorecase, allowRelativePaths = false, } = {}) {
471
+ define(this, KEY_IGNORE, true);
472
+ this._rules = new RuleManager(ignoreCase);
473
+ this._strictPathCheck = !allowRelativePaths;
474
+ this._initCache();
475
+ }
476
+ _initCache() {
477
+ // A cache for the result of `.ignores()`
478
+ this._ignoreCache = Object.create(null);
479
+ // A cache for the result of `.test()`
480
+ this._testCache = Object.create(null);
481
+ }
482
+ add(pattern) {
483
+ if (this._rules.add(pattern)) {
484
+ // Some rules have just added to the ignore,
485
+ // making the behavior changed,
486
+ // so we need to re-initialize the result cache
487
+ this._initCache();
488
+ }
489
+ return this;
490
+ }
491
+ // legacy
492
+ addPattern(pattern) {
493
+ return this.add(pattern);
494
+ }
495
+ // @returns {TestResult}
496
+ _test(originalPath, cache, checkUnignored, slices) {
497
+ const path = originalPath &&
498
+ // Supports nullable path
499
+ checkPath.convert(originalPath);
500
+ checkPath(path, originalPath, this._strictPathCheck ? throwError : RETURN_FALSE);
501
+ return this._t(path, cache, checkUnignored, slices);
502
+ }
503
+ checkIgnore(path) {
504
+ // If the path doest not end with a slash, `.ignores()` is much equivalent
505
+ // to `git check-ignore`
506
+ if (!REGEX_TEST_TRAILING_SLASH.test(path)) {
507
+ return this.test(path);
508
+ }
509
+ const slices = path.split(SLASH).filter(Boolean);
510
+ slices.pop();
511
+ if (slices.length) {
512
+ const parent = this._t(slices.join(SLASH) + SLASH, this._testCache, true, slices);
513
+ if (parent.ignored) {
514
+ return parent;
515
+ }
516
+ }
517
+ return this._rules.test(path, false, MODE_CHECK_IGNORE);
518
+ }
519
+ _t(
520
+ // The path to be tested
521
+ path,
522
+ // The cache for the result of a certain checking
523
+ cache,
524
+ // Whether should check if the path is unignored
525
+ checkUnignored,
526
+ // The path slices
527
+ slices) {
528
+ if (path in cache) {
529
+ return cache[path];
530
+ }
531
+ if (!slices) {
532
+ // path/to/a.js
533
+ // ['path', 'to', 'a.js']
534
+ slices = path.split(SLASH).filter(Boolean);
535
+ }
536
+ slices.pop();
537
+ // If the path has no parent directory, just test it
538
+ if (!slices.length) {
539
+ return (cache[path] = this._rules.test(path, checkUnignored, MODE_IGNORE));
540
+ }
541
+ const parent = this._t(slices.join(SLASH) + SLASH, cache, checkUnignored, slices);
542
+ // If the path contains a parent directory, check the parent first
543
+ return (cache[path] = parent.ignored
544
+ ? // > It is not possible to re-include a file if a parent directory of
545
+ // > that file is excluded.
546
+ parent
547
+ : this._rules.test(path, checkUnignored, MODE_IGNORE));
548
+ }
549
+ ignores(path) {
550
+ return this._test(path, this._ignoreCache, false).ignored;
551
+ }
552
+ createFilter() {
553
+ return (path) => !this.ignores(path);
554
+ }
555
+ filter(paths) {
556
+ return makeArray(paths).filter(this.createFilter());
557
+ }
558
+ // @returns {TestResult}
559
+ test(path) {
560
+ return this._test(path, this._testCache, true);
561
+ }
562
+ }
563
+ const factory = (options) => new Ignore(options);
564
+ const isPathValid = (path) => checkPath(path && checkPath.convert(path), path, RETURN_FALSE);
565
+ /* istanbul ignore next */
566
+ const setupWindows = () => {
567
+ /* eslint no-control-regex: "off" */
568
+ const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str)
569
+ ? str
570
+ : str.replace(/\\/g, "/");
571
+ checkPath.convert = makePosix;
572
+ // 'C:\\foo' <- 'C:\\foo' has been converted to 'C:/'
573
+ // 'd:\\foo'
574
+ const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
575
+ checkPath.isNotRelative = (path) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path) || isNotRelative(path);
576
+ };
577
+ // Windows
578
+ // --------------------------------------------------------------
579
+ /* istanbul ignore next */
580
+ if (
581
+ // Detect `process` so that it can run in browsers.
582
+ typeof process !== "undefined" &&
583
+ process.platform === "win32") {
584
+ setupWindows();
585
+ }
586
+ // ES module exports (upstream uses `module.exports`). Upstream also exposes
587
+ // `setupWindows` via `Symbol.for("setupWindows")` for its own test suite; we
588
+ // drop that hook since it's unused.
589
+ export default factory;
590
+ export { isPathValid };
591
+ //# sourceMappingURL=ignore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ignore.js","sourceRoot":"","sources":["../src/ignore.ts"],"names":[],"mappings":"AAAA,cAAc;AACd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,wCAAwC;AACxC,SAAS,SAAS,CAAC,OAAO;IACxB,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,SAAS,GAAG,SAAS,CAAC;AAC5B,MAAM,KAAK,GAAG,EAAE,CAAC;AACjB,MAAM,KAAK,GAAG,GAAG,CAAC;AAClB,MAAM,MAAM,GAAG,IAAI,CAAC;AACpB,MAAM,qBAAqB,GAAG,OAAO,CAAC;AACtC,MAAM,gCAAgC,GAAG,gBAAgB,CAAC;AAC1D,MAAM,yCA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