@putout/engine-runner 12.1.1 → 12.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 CHANGED
@@ -322,12 +322,11 @@ const places = runPlugins({
322
322
 
323
323
  To see logs, use:
324
324
 
325
- ```sh
326
- DEBUG=putout:runner:*
327
- DEBUG=putout:runner:fix
328
- DEBUG=putout:runner:find
329
- DEBUG=putout:runner:template
330
- ```
325
+ - ✅ `DEBUG=putout:runner:*`
326
+ - ✅ `DEBUG=putout:runner:fix`
327
+ - ✅ `DEBUG=putout:runner:find`
328
+ - ✅ `DEBUG=putout:runner:template`
329
+ - ✅ `DEBUG=putout:runner:replace`
331
330
 
332
331
  ## License
333
332
 
package/lib/index.js CHANGED
@@ -137,11 +137,15 @@ function splitPlugins(plugins, {template}) {
137
137
  for (const item of plugins) {
138
138
  const {plugin} = item;
139
139
 
140
- if (plugin.find)
140
+ if (plugin.find) {
141
141
  pluginsFind.push(item);
142
+ continue;
143
+ }
142
144
 
143
- if (plugin.traverse)
145
+ if (plugin.traverse) {
144
146
  pluginsTraverse.push(item);
147
+ continue;
148
+ }
145
149
 
146
150
  if (plugin.replace) {
147
151
  pluginsTraverse.push(include(replace(item, {
@@ -11,10 +11,15 @@ const {
11
11
  getValues,
12
12
  setValues,
13
13
  } = require('@putout/compare');
14
+ const debug = require('debug')('putout:runner:replace');
14
15
 
15
16
  const maybeArray = require('../maybe-array');
16
17
  const watermark = require('./watermark');
17
18
 
19
+ const log = (from, path) => {
20
+ debug.enabled && debug(`${from} -> ${path}\n`);
21
+ };
22
+
18
23
  const {keys, entries} = Object;
19
24
  const {stringify} = JSON;
20
25
 
@@ -89,8 +94,10 @@ const fix = (from, to, path) => {
89
94
 
90
95
  const nodeTo = parseTo(to, values, path);
91
96
 
92
- if (!nodeTo)
97
+ if (!nodeTo) {
98
+ log(from, `''`);
93
99
  return remove(path);
100
+ }
94
101
 
95
102
  const waysTo = findVarsWays(nodeTo);
96
103
  const newPath = replaceWith(path, nodeTo);
@@ -105,7 +112,8 @@ const fix = (from, to, path) => {
105
112
 
106
113
  mark.add();
107
114
  path.scope.getBlockParent().crawl();
108
- path.scope.getProgramParent().crawl();
115
+
116
+ log(from, newPath);
109
117
  };
110
118
 
111
119
  const getFix = (items) => (path) => {
package/lib/run-fix.js CHANGED
@@ -6,9 +6,14 @@ const {enabled} = debug;
6
6
 
7
7
  const tryToFix = (fix, {path, position, options}) => {
8
8
  const [e] = tryCatch(fix, path, {options});
9
+ const {scope} = path.path || path;
9
10
 
10
- if (!e)
11
+ if (!e && scope)
12
+ scope.getProgramParent().crawl();
13
+
14
+ if (!e) {
11
15
  return;
16
+ }
12
17
 
13
18
  e.loc = e.loc || position;
14
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/engine-runner",
3
- "version": "12.1.1",
3
+ "version": "12.4.1",
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
  "@babel/types": "^7.12.7",
29
29
  "@putout/compare": "^8.0.0",
30
30
  "@putout/engine-parser": "^4.0.1",
31
- "@putout/operate": "^6.0.0",
31
+ "@putout/operate": "^7.0.0",
32
32
  "debug": "^4.1.1",
33
33
  "jessy": "^3.0.0",
34
34
  "nessy": "^4.0.0",
@@ -46,7 +46,7 @@
46
46
  "c8": "^7.5.0",
47
47
  "eslint": "^8.0.1",
48
48
  "eslint-plugin-node": "^11.0.0",
49
- "eslint-plugin-putout": "^12.0.0",
49
+ "eslint-plugin-putout": "^13.0.0",
50
50
  "just-camel-case": "^4.0.2",
51
51
  "lerna": "^4.0.0",
52
52
  "madrun": "^8.0.1",