redlint 3.21.2 → 3.21.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.
package/ChangeLog
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import {basename
|
|
1
|
+
import {basename} from 'node:path';
|
|
2
2
|
import {operator} from 'putout';
|
|
3
3
|
|
|
4
|
-
const {
|
|
4
|
+
const {
|
|
5
|
+
getFilename,
|
|
6
|
+
readDirectory,
|
|
7
|
+
findFile,
|
|
8
|
+
} = operator;
|
|
5
9
|
|
|
6
10
|
export const report = (path, {name}) => name;
|
|
7
11
|
export const fix = () => {};
|
|
8
|
-
export const scan = (
|
|
12
|
+
export const scan = (rootPath, {push, options}) => {
|
|
13
|
+
console.time('scan');
|
|
14
|
+
|
|
9
15
|
const {
|
|
10
16
|
dir = '/',
|
|
11
17
|
full,
|
|
@@ -13,28 +19,22 @@ export const scan = (path, {push, trackFile, options}) => {
|
|
|
13
19
|
} = options;
|
|
14
20
|
|
|
15
21
|
const names = [];
|
|
22
|
+
const [dirPath] = findFile(rootPath, dir);
|
|
23
|
+
|
|
24
|
+
const files = recursive ? findFile(dirPath, '*') : readDirectory(dirPath);
|
|
16
25
|
|
|
17
|
-
for (const file of
|
|
26
|
+
for (const file of files) {
|
|
18
27
|
const path = getFilename(file);
|
|
19
|
-
const currentDir = dirname(path);
|
|
20
28
|
|
|
21
29
|
if (dir === path)
|
|
22
30
|
continue;
|
|
23
31
|
|
|
24
|
-
if (!recursive && currentDir !== dir)
|
|
25
|
-
continue;
|
|
26
|
-
|
|
27
32
|
if (!full && recursive) {
|
|
28
33
|
const name = path
|
|
29
34
|
.replace(dir, '')
|
|
30
35
|
.replace(/^\//, '');
|
|
31
36
|
|
|
32
|
-
|
|
33
|
-
continue;
|
|
34
|
-
|
|
35
|
-
push(file, {
|
|
36
|
-
name,
|
|
37
|
-
});
|
|
37
|
+
names.push(name);
|
|
38
38
|
continue;
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -46,7 +46,7 @@ export const scan = (path, {push, trackFile, options}) => {
|
|
|
46
46
|
const sorted = names.sort();
|
|
47
47
|
|
|
48
48
|
for (const name of sorted) {
|
|
49
|
-
push(
|
|
49
|
+
push(dirPath, {
|
|
50
50
|
name,
|
|
51
51
|
});
|
|
52
52
|
}
|