@putout/engine-runner 20.3.0 → 20.4.1
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/README.md +15 -0
- package/lib/scanner/index.js +29 -5
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -254,6 +254,21 @@ export const scan = (rootPath) => {
|
|
|
254
254
|
};
|
|
255
255
|
```
|
|
256
256
|
|
|
257
|
+
Or better `trackFile`, which does the same, but also count `progress`:
|
|
258
|
+
|
|
259
|
+
```js
|
|
260
|
+
export const report = () => 'Add file';
|
|
261
|
+
export const fix = (file) => {
|
|
262
|
+
writeFileContent(file, 'hello');
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
export const scan = (rootPath, {push, trackFile}) => {
|
|
266
|
+
for (const file of trackFile(rootPath, 'hello.txt')) {
|
|
267
|
+
push(file);
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
```
|
|
271
|
+
|
|
257
272
|
### Finder
|
|
258
273
|
|
|
259
274
|
**Finder** gives you all the control over traversing, but it's the slowest format.
|
package/lib/scanner/index.js
CHANGED
|
@@ -3,7 +3,13 @@
|
|
|
3
3
|
const fullstore = require('fullstore');
|
|
4
4
|
const {compare} = require('@putout/compare');
|
|
5
5
|
const {__filesystem_name} = require('@putout/operator-json');
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
findFile,
|
|
9
|
+
pause,
|
|
10
|
+
start,
|
|
11
|
+
} = require('@putout/operator-filesystem');
|
|
12
|
+
|
|
7
13
|
const log = require('debug')('putout:runner:scanner');
|
|
8
14
|
|
|
9
15
|
const fromSimple = require('@putout/plugin-filesystem/from-simple');
|
|
@@ -53,6 +59,19 @@ const createFileProgress = ({rule, progress}) => ({i, n}) => {
|
|
|
53
59
|
});
|
|
54
60
|
};
|
|
55
61
|
|
|
62
|
+
const createTrackFile = (fileProgress) => function*(...a) {
|
|
63
|
+
const files = findFile(...a);
|
|
64
|
+
const n = files.length;
|
|
65
|
+
|
|
66
|
+
for (const [i, file] of files.entries()) {
|
|
67
|
+
fileProgress({
|
|
68
|
+
i,
|
|
69
|
+
n,
|
|
70
|
+
});
|
|
71
|
+
yield file;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
56
75
|
const getTraverse = ({scan, rule, progress}) => ({push, options}) => ({
|
|
57
76
|
['__putout_processor_filesystem(__)'](path) {
|
|
58
77
|
log(rule);
|
|
@@ -61,6 +80,13 @@ const getTraverse = ({scan, rule, progress}) => ({push, options}) => ({
|
|
|
61
80
|
const rootPath = path.get('arguments.0');
|
|
62
81
|
const isSimple = fullstore(false);
|
|
63
82
|
|
|
83
|
+
const fileProgress = createFileProgress({
|
|
84
|
+
rule,
|
|
85
|
+
progress,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const trackFile = createTrackFile(fileProgress);
|
|
89
|
+
|
|
64
90
|
runSimple(fromSimple, {
|
|
65
91
|
path,
|
|
66
92
|
rootPath,
|
|
@@ -73,10 +99,8 @@ const getTraverse = ({scan, rule, progress}) => ({push, options}) => ({
|
|
|
73
99
|
rule,
|
|
74
100
|
progress,
|
|
75
101
|
}),
|
|
76
|
-
progress:
|
|
77
|
-
|
|
78
|
-
progress,
|
|
79
|
-
}),
|
|
102
|
+
progress: fileProgress,
|
|
103
|
+
trackFile,
|
|
80
104
|
options,
|
|
81
105
|
});
|
|
82
106
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/engine-runner",
|
|
3
|
-
"version": "20.
|
|
3
|
+
"version": "20.4.1",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "Run 🐊Putout plugins",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@putout/operate": "^12.0.0",
|
|
35
35
|
"@putout/operator-declare": "^9.0.0",
|
|
36
36
|
"@putout/operator-filesystem": "^3.0.0",
|
|
37
|
-
"@putout/operator-json": "^
|
|
37
|
+
"@putout/operator-json": "^2.0.0",
|
|
38
38
|
"@putout/plugin-filesystem": "^3.0.0",
|
|
39
39
|
"debug": "^4.1.1",
|
|
40
40
|
"fullstore": "^3.0.0",
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
],
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@putout/plugin-minify": "*",
|
|
53
|
-
"c8": "^
|
|
54
|
-
"eslint": "^
|
|
55
|
-
"eslint-plugin-n": "^
|
|
53
|
+
"c8": "^9.0.0",
|
|
54
|
+
"eslint": "^9.0.0-alpha.0",
|
|
55
|
+
"eslint-plugin-n": "^17.0.0-0",
|
|
56
56
|
"eslint-plugin-putout": "^22.0.0",
|
|
57
57
|
"just-camel-case": "^4.0.2",
|
|
58
58
|
"lerna": "^6.0.1",
|