redlint 3.22.3 → 3.22.5
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
package/lib/edit/README.md
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
|
|
3
3
|
- ✅[read-directory](https://putout.cloudcmd.io/#/gist/df334cfe8c45c273c4745f0d97f123c7/956fd7607dafc3431e7d531d33810286e5ecbdc5);
|
|
4
4
|
- ✅[rename-files](https://putout.cloudcmd.io/#/gist/eea361b01e553f5938faba49998225e3/1bbd9b4b61758a0c15d0331d8159eb0996e592cc);
|
|
5
|
-
- ✅[rename-files-full](https://putout.cloudcmd.io/#/gist/
|
|
5
|
+
- ✅[rename-files-full](https://putout.cloudcmd.io/#/gist/fea52fe6cd41aff04846e1487cbc605a/fc2ac6e08e80d2eb9a81ca0306436027cb70e78c);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {basename} from 'node:path';
|
|
2
2
|
import {operator} from 'putout';
|
|
3
|
+
import {getFileType} from '@putout/operator-filesystem';
|
|
3
4
|
|
|
4
5
|
const {
|
|
5
6
|
getFilename,
|
|
@@ -10,8 +11,6 @@ const {
|
|
|
10
11
|
export const report = (path, {name}) => name;
|
|
11
12
|
export const fix = () => {};
|
|
12
13
|
export const scan = (rootPath, {push, options}) => {
|
|
13
|
-
console.time('scan');
|
|
14
|
-
|
|
15
14
|
const {
|
|
16
15
|
dir = '/',
|
|
17
16
|
full,
|
|
@@ -24,13 +23,17 @@ export const scan = (rootPath, {push, options}) => {
|
|
|
24
23
|
const files = nested ? findFile(dirPath, '*') : readDirectory(dirPath);
|
|
25
24
|
|
|
26
25
|
for (const file of files) {
|
|
27
|
-
const
|
|
26
|
+
const currentPath = getFilename(file);
|
|
27
|
+
const type = getFileType(file);
|
|
28
|
+
|
|
29
|
+
if (dir === currentPath)
|
|
30
|
+
continue;
|
|
28
31
|
|
|
29
|
-
if (
|
|
32
|
+
if (nested && type === 'directory')
|
|
30
33
|
continue;
|
|
31
34
|
|
|
32
35
|
if (!full && nested) {
|
|
33
|
-
const name =
|
|
36
|
+
const name = currentPath
|
|
34
37
|
.replace(dir, '')
|
|
35
38
|
.replace(/^\//, '');
|
|
36
39
|
|
|
@@ -38,7 +41,7 @@ export const scan = (rootPath, {push, options}) => {
|
|
|
38
41
|
continue;
|
|
39
42
|
}
|
|
40
43
|
|
|
41
|
-
const name = full ?
|
|
44
|
+
const name = full ? currentPath : basename(currentPath);
|
|
42
45
|
|
|
43
46
|
names.push(name);
|
|
44
47
|
}
|
|
@@ -51,3 +54,4 @@ export const scan = (rootPath, {push, options}) => {
|
|
|
51
54
|
});
|
|
52
55
|
}
|
|
53
56
|
};
|
|
57
|
+
|
|
@@ -8,7 +8,7 @@ const {
|
|
|
8
8
|
getFilename,
|
|
9
9
|
getParentDirectory,
|
|
10
10
|
removeFile,
|
|
11
|
-
|
|
11
|
+
removeEmptyDirectory,
|
|
12
12
|
} = operator;
|
|
13
13
|
|
|
14
14
|
export const report = (filePath, {from, to}) => `Rename '${from}' to '${to}'`;
|
|
@@ -24,7 +24,7 @@ export const fix = (filePath, {to}) => {
|
|
|
24
24
|
const dir = getParentDirectory(filePath);
|
|
25
25
|
|
|
26
26
|
removeFile(filePath);
|
|
27
|
-
|
|
27
|
+
removeEmptyDirectory(dir);
|
|
28
28
|
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
@@ -104,18 +104,3 @@ function isEqual(a, b) {
|
|
|
104
104
|
|
|
105
105
|
return is;
|
|
106
106
|
}
|
|
107
|
-
|
|
108
|
-
function removeEmptyNestedDirectory(parentDir) {
|
|
109
|
-
let nextParentDir = parentDir;
|
|
110
|
-
|
|
111
|
-
while (!readDirectory(parentDir).length) {
|
|
112
|
-
const name = getFilename(parentDir);
|
|
113
|
-
|
|
114
|
-
if (name === '/')
|
|
115
|
-
break;
|
|
116
|
-
|
|
117
|
-
nextParentDir = getParentDirectory(parentDir);
|
|
118
|
-
removeFile(parentDir);
|
|
119
|
-
parentDir = nextParentDir;
|
|
120
|
-
}
|
|
121
|
-
}
|