@putout/engine-runner 23.1.1 → 23.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/lib/index.js CHANGED
@@ -13,6 +13,7 @@ const declare = require('./declare');
13
13
  const scanner = require('./scanner');
14
14
  const template = require('./template');
15
15
  const {createProgress} = require('./progress');
16
+ const {tryThrowWithReason} = require('./try-throw-with-reason');
16
17
 
17
18
  const {getPath, getPosition} = require('./get-position');
18
19
 
@@ -80,7 +81,7 @@ function runWithMerge({ast, fix, shebang, template, pluginsTraverse, merge, trav
80
81
  template,
81
82
  });
82
83
 
83
- traverse(ast, visitor);
84
+ tryThrowWithReason(traverse, ast, visitor);
84
85
 
85
86
  const places = [];
86
87
 
@@ -107,7 +108,7 @@ function runWithoutMerge({ast, fix, shebang, template, pluginsFind}) {
107
108
 
108
109
  const {report, find} = plugin;
109
110
 
110
- const items = superFind({
111
+ const items = tryThrowWithReason(superFind, {
111
112
  rule,
112
113
  find,
113
114
  ast,
@@ -16,9 +16,7 @@ const {
16
16
  pathStore,
17
17
  } = require('./store');
18
18
 
19
- const shouldSkip = (a) => !a.parent;
20
19
  const {merge} = traverse.visitors;
21
-
22
20
  const {assign} = Object;
23
21
 
24
22
  const parse = (name, plugin, options) => {
@@ -87,7 +85,7 @@ module.exports = (pluginsToMerge, {fix, shebang, template}) => {
87
85
  const entries = Object.entries(pushed);
88
86
 
89
87
  const visitor = {
90
- shouldSkip,
88
+ //shouldSkip,
91
89
  ...merge(mergeItems),
92
90
  };
93
91
 
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ const tryCatch = require('try-catch');
4
+
5
+ module.exports.tryThrowWithReason = (fn, ...args) => {
6
+ const [error, result] = tryCatch(fn, ...args);
7
+
8
+ if (error) {
9
+ error.reason = 'traverse';
10
+ throw error;
11
+ }
12
+
13
+ return result;
14
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/engine-runner",
3
- "version": "23.1.1",
3
+ "version": "23.2.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Run 🐊Putout plugins",