@awesomeness-js/utils 1.0.25 → 1.1.3

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.
@@ -1,63 +0,0 @@
1
- export default function shouldIgnore(filePath, ignorePatterns) {
2
-
3
- // filePath is already something like "/css/some.js"
4
- return ignorePatterns.some((pattern) => {
5
-
6
- // pattern might be "/css/*.js" or "/ignoreFolder", etc.
7
- let normalizedPattern = pattern.replace(/\\/g, '/');
8
-
9
- // 1) Full directory ignore: "/ignoreFolder" => ignore "/ignoreFolder" + subdirectories
10
- // If the pattern ends with "/", treat it as a directory path.
11
- if (!normalizedPattern.includes('*')) {
12
-
13
- // e.g. "/ignoreFolder/"
14
- if (normalizedPattern.endsWith('/')) {
15
-
16
- normalizedPattern = normalizedPattern.slice(0, -1); // remove trailing slash
17
-
18
- }
19
-
20
- return filePath === normalizedPattern || filePath.startsWith(normalizedPattern + '/');
21
-
22
- }
23
-
24
- // 2) folder/* => Ignore all immediate children in that folder (no subfolders)
25
- if (normalizedPattern.endsWith('/*')) {
26
-
27
- const baseFolder = normalizedPattern.slice(0, -2); // e.g. "/css"
28
- // e.g. filePath === "/css/some.js" => startsWith("/css/")
29
- // But also ensure there's no further subfolder.
30
-
31
- return filePath.startsWith(baseFolder + '/') &&
32
- !filePath.slice(baseFolder.length + 1).includes('/');
33
-
34
- }
35
-
36
- // 3) *.ext => extension-based ignore (any folder)
37
- if (normalizedPattern.startsWith('*.')) {
38
-
39
- const ext = normalizedPattern.slice(1); // remove '*'
40
-
41
-
42
- return filePath.endsWith(ext);
43
-
44
- }
45
-
46
- // 4) folder/*.ext => only files with that extension in that folder (no subfolders)
47
- if (normalizedPattern.includes('/*')) {
48
-
49
- const [ baseFolder, ext ] = normalizedPattern.split('/*');
50
-
51
-
52
- return filePath.startsWith(baseFolder + '/') &&
53
- filePath.endsWith(ext) &&
54
- !filePath.slice(baseFolder.length + 1).includes('/');
55
-
56
- }
57
-
58
- // 5) Exact match
59
- return filePath === normalizedPattern;
60
-
61
- });
62
-
63
- }