@putout/cli-process-file 2.3.1 → 2.4.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.
@@ -1,11 +1,13 @@
1
1
  'use strict';
2
2
 
3
+ const process = require('node:process');
3
4
  const tryToCatch = require('try-to-catch');
4
5
  const eslint = require('@putout/eslint');
5
6
  const {parseMatch} = require('putout/parse-match');
6
7
  const {mergeOptions} = require('putout/merge-options');
7
8
  const parseError = require('putout/parse-error');
8
9
  const {putoutAsync} = require('putout');
10
+ const once = require('once');
9
11
 
10
12
  const {simpleImport: _simpleImport} = require('./simple-import');
11
13
 
@@ -16,6 +18,8 @@ const getMatchedOptions = (name, options) => {
16
18
  return mergeOptions(options, parseMatch(name, options.match));
17
19
  };
18
20
 
21
+ const getEnv = once(() => process.env);
22
+
19
23
  module.exports = ({fix, fixCount, logError, raw}) => async function processFile(overrides) {
20
24
  const {
21
25
  name = '<input>',
@@ -23,6 +27,7 @@ module.exports = ({fix, fixCount, logError, raw}) => async function processFile(
23
27
  startLine,
24
28
  options = {},
25
29
  again,
30
+ env = getEnv(),
26
31
  simpleImport = _simpleImport,
27
32
  } = overrides;
28
33
 
@@ -38,9 +43,11 @@ module.exports = ({fix, fixCount, logError, raw}) => async function processFile(
38
43
  printer: configurePrinter(name, printer),
39
44
  });
40
45
 
41
- raw && logError(e);
46
+ e && raw && logError(e);
47
+
48
+ const {FLATLINT} = env;
42
49
 
43
- if (!again && e && e.reason === 'parse') {
50
+ if (FLATLINT || !again && e && e.reason === 'parse') {
44
51
  const {lint} = await simpleImport('samadhi');
45
52
  const [code, places] = await lint(source, {
46
53
  startLine,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/cli-process-file",
3
- "version": "2.3.1",
3
+ "version": "2.4.0",
4
4
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
5
5
  "description": "Run all 🐊Putout linters",
6
6
  "homepage": "https://github.com/coderaiser/putout/tree/master/packages/cli-process-file#readme",
@@ -27,6 +27,7 @@
27
27
  "@putout/eslint": "^4.0.0",
28
28
  "@putout/formatter-eslint": "^2.0.2",
29
29
  "deepmerge": "^4.3.1",
30
+ "once": "^1.4.0",
30
31
  "samadhi": "^2.14.1",
31
32
  "try-catch": "^3.0.0",
32
33
  "try-to-catch": "^3.0.0"