@putout/engine-runner 20.1.0 → 20.2.0

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 CHANGED
@@ -214,13 +214,13 @@ module.exports.fix = (rootPath) => {
214
214
  createFile(rootPath, 'hello.txt', 'hello world');
215
215
  };
216
216
 
217
- module.exports.scan = (rootPath) => {
217
+ module.exports.scan = (rootPath, {push}) => {
218
218
  const [filePath] = findFile(rootPath, 'hello.txt');
219
219
 
220
220
  if (filePath)
221
221
  return null;
222
222
 
223
- return rootPath;
223
+ push(rootPath);
224
224
  };
225
225
  ```
226
226
 
@@ -230,6 +230,32 @@ You can also subscribe to `progress` events:
230
230
  - `end`;
231
231
  - `push`;
232
232
 
233
+ And one more: `file` if your plugin uses `progress` function:
234
+
235
+ ```js
236
+ export const report = () => 'Create file hello.txt';
237
+
238
+ export const fix = (rootPath) => {
239
+ createFile(rootPath, 'hello.txt', 'hello world');
240
+ };
241
+
242
+ export const scan = (rootPath) => {
243
+ const [filePath] = findFile(rootPath, 'hello.txt');
244
+
245
+ if (filePath)
246
+ return null;
247
+
248
+ progress({
249
+ i: 0,
250
+ n: 1,
251
+ });
252
+
253
+ push(filePath);
254
+ };
255
+ ```
256
+
257
+
258
+
233
259
  ### Finder
234
260
 
235
261
  **Finder** gives you all the control over traversing, but it's the slowest format.
package/lib/progress.js CHANGED
@@ -13,6 +13,14 @@ module.exports.createProgress = () => {
13
13
  pluginsCount = 0;
14
14
  };
15
15
 
16
+ progress.file = ({i, n, rule}) => {
17
+ progress.emit('file', {
18
+ i,
19
+ n,
20
+ rule,
21
+ });
22
+ };
23
+
16
24
  progress.inc = () => {
17
25
  ++pluginsCount;
18
26
  };
@@ -41,6 +41,14 @@ const watchPush = ({push, rule, progress}) => (...a) => {
41
41
  push(...a);
42
42
  };
43
43
 
44
+ const createFileProgress = ({rule, progress}) => ({i, n}) => {
45
+ progress.file({
46
+ i,
47
+ n,
48
+ rule,
49
+ });
50
+ };
51
+
44
52
  const getTraverse = ({scan, rule, progress}) => ({push, options}) => ({
45
53
  ['__putout_processor_filesystem(__)'](path) {
46
54
  log(rule);
@@ -61,6 +69,10 @@ const getTraverse = ({scan, rule, progress}) => ({push, options}) => ({
61
69
  rule,
62
70
  progress,
63
71
  }),
72
+ progress: createFileProgress({
73
+ rule,
74
+ progress,
75
+ }),
64
76
  options,
65
77
  });
66
78
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/engine-runner",
3
- "version": "20.1.0",
3
+ "version": "20.2.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Run 🐊Putout plugins",