redlint 1.0.4 → 1.0.6
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 +10 -0
- package/bin/redlint.js +0 -0
- package/lib/redlint.js +16 -6
- package/package.json +1 -1
package/ChangeLog
CHANGED
package/bin/redlint.js
CHANGED
|
File without changes
|
package/lib/redlint.js
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
import ignore from 'ignore';
|
|
2
|
-
import
|
|
3
|
-
import {opendir} from 'node:fs/promises';
|
|
2
|
+
import parseOptionsOriginal from 'putout/parse-options';
|
|
3
|
+
import {opendir as opendirOriginal} from 'node:fs/promises';
|
|
4
4
|
|
|
5
5
|
const resolveName = (name, cwd) => name.replace(`${cwd}/`, '');
|
|
6
6
|
|
|
7
|
-
export const buildTree = async (cwd) => {
|
|
7
|
+
export const buildTree = async (cwd, {parseOptions = parseOptionsOriginal, opendir = opendirOriginal} = {}) => {
|
|
8
8
|
const options = parseOptions();
|
|
9
9
|
const ig = ignore().add(options.ignore.filter(isExcluded));
|
|
10
10
|
|
|
11
11
|
return {
|
|
12
12
|
type: 'directory',
|
|
13
13
|
filename: cwd,
|
|
14
|
-
files: await walk(
|
|
14
|
+
files: await walk({
|
|
15
|
+
cwd,
|
|
16
|
+
dir: cwd,
|
|
17
|
+
ignore: ig,
|
|
18
|
+
opendir,
|
|
19
|
+
}),
|
|
15
20
|
};
|
|
16
21
|
};
|
|
17
22
|
|
|
18
|
-
async function walk(cwd, dir, ignore, files = []) {
|
|
23
|
+
async function walk({cwd, dir, ignore, files = [], opendir}) {
|
|
19
24
|
for await (const dirent of await opendir(dir)) {
|
|
20
25
|
const {path, name} = dirent;
|
|
21
26
|
const filename = `${path}/${name}`;
|
|
@@ -28,7 +33,12 @@ async function walk(cwd, dir, ignore, files = []) {
|
|
|
28
33
|
files.push({
|
|
29
34
|
type: 'directory',
|
|
30
35
|
filename,
|
|
31
|
-
files: await walk(
|
|
36
|
+
files: await walk({
|
|
37
|
+
cwd,
|
|
38
|
+
dir: filename,
|
|
39
|
+
ignore,
|
|
40
|
+
opendir,
|
|
41
|
+
}),
|
|
32
42
|
});
|
|
33
43
|
continue;
|
|
34
44
|
}
|