@putout/engine-runner 22.0.4 → 22.1.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/lib/index.js CHANGED
@@ -53,25 +53,23 @@ module.exports.runPlugins = ({ast, shebang, fix, fixCount, plugins, progress = c
53
53
 
54
54
  module.exports.getPosition = getPosition;
55
55
 
56
- function run({ast, fix, shebang, pluginsFind, pluginsTraverse, template, merge}) {
57
- return [
58
- ...runWithoutMerge({
59
- ast,
60
- fix,
61
- shebang,
62
- template,
63
- pluginsFind,
64
- }),
65
- ...runWithMerge({
66
- ast,
67
- fix,
68
- shebang,
69
- template,
70
- pluginsTraverse,
71
- merge,
72
- }),
73
- ];
74
- }
56
+ const run = ({ast, fix, shebang, pluginsFind, pluginsTraverse, template, merge}) => [
57
+ ...runWithoutMerge({
58
+ ast,
59
+ fix,
60
+ shebang,
61
+ template,
62
+ pluginsFind,
63
+ }),
64
+ ...runWithMerge({
65
+ ast,
66
+ fix,
67
+ shebang,
68
+ template,
69
+ pluginsTraverse,
70
+ merge,
71
+ }),
72
+ ];
75
73
 
76
74
  function runWithMerge({ast, fix, shebang, template, pluginsTraverse, merge}) {
77
75
  const {entries, visitor} = merge(pluginsTraverse, {
@@ -1,8 +1,10 @@
1
1
  'use strict';
2
2
 
3
3
  const wraptile = require('wraptile');
4
- const findPath = require('./find-path');
4
+
5
5
  const {types} = require('@putout/babel');
6
+ const findPath = require('./find-path');
7
+
6
8
  const {isProgram} = types;
7
9
  const name = '__putout_runner_replace';
8
10
  const hasWatermark = (watermark) => (path) => path.node?.[name]?.has(watermark);
package/lib/super-find.js CHANGED
@@ -30,14 +30,12 @@ module.exports = function superFind({rule, find, ast, options, template}) {
30
30
  ];
31
31
  };
32
32
 
33
- function traverse({rule, options, template}) {
34
- return (ast, visitor) => {
35
- const templateVisitors = merge(template({
36
- rule,
37
- visitor,
38
- options,
39
- }));
40
-
41
- return babelTraverse(ast, templateVisitors);
42
- };
43
- }
33
+ const traverse = ({rule, options, template}) => (ast, visitor) => {
34
+ const templateVisitors = merge(template({
35
+ rule,
36
+ visitor,
37
+ options,
38
+ }));
39
+
40
+ return babelTraverse(ast, templateVisitors);
41
+ };
@@ -82,24 +82,22 @@ module.exports = ({rule, visitor, options}) => {
82
82
 
83
83
  module.exports._log = log;
84
84
 
85
- function wrapWithCheck({rule, nodesInclude, nodesExclude, fn}) {
86
- return (path) => {
87
- log(rule, path);
88
-
89
- if (nodesExclude.length && compareAny(path, nodesExclude))
90
- return;
91
-
92
- if (nodesInclude.length && !compareAll(path, nodesInclude))
93
- return;
94
-
95
- if (!isFn(fn))
96
- throw Error(`☝️ Looks like provided visitor is not a function: ${stringify(fn)}. More on using Traverser: https://git.io/JqcMn`);
97
-
98
- const [e] = tryCatch(fn, path);
99
-
100
- if (e) {
101
- e.rule = rule;
102
- throw e;
103
- }
104
- };
105
- }
85
+ const wrapWithCheck = ({rule, nodesInclude, nodesExclude, fn}) => (path) => {
86
+ log(rule, path);
87
+
88
+ if (nodesExclude.length && compareAny(path, nodesExclude))
89
+ return;
90
+
91
+ if (nodesInclude.length && !compareAll(path, nodesInclude))
92
+ return;
93
+
94
+ if (!isFn(fn))
95
+ throw Error(`☝️ Looks like provided visitor is not a function: ${stringify(fn)}. More on using Traverser: https://git.io/JqcMn`);
96
+
97
+ const [e] = tryCatch(fn, path);
98
+
99
+ if (e) {
100
+ e.rule = rule;
101
+ throw e;
102
+ }
103
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/engine-runner",
3
- "version": "22.0.4",
3
+ "version": "22.1.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Run 🐊Putout plugins",
@@ -28,7 +28,7 @@
28
28
  "report": "madrun report"
29
29
  },
30
30
  "dependencies": {
31
- "@putout/babel": "^2.0.0",
31
+ "@putout/babel": "^3.0.0",
32
32
  "@putout/compare": "^15.0.0",
33
33
  "@putout/engine-parser": "^11.0.0",
34
34
  "@putout/operate": "^12.0.0",