@putout/engine-reporter 5.0.1 → 7.0.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.
@@ -0,0 +1,3 @@
1
+ import {stub} from 'supertape';
2
+
3
+ export const chooseFormatter = stub().resolves(['dump']);
@@ -0,0 +1,3 @@
1
+ import {stub} from 'supertape';
2
+
3
+ export const chooseFormatter = stub().resolves([]);
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const {simpleImport} = require('putout/simple-import');
4
- const {createAsyncLoader} = require('@putout/engine-loader');
3
+ const {simpleImport: _simpleImport} = require('putout/simple-import');
4
+ const {createAsyncLoader: _createAsyncLoader} = require('@putout/engine-loader');
5
5
 
6
6
  const tryToCatch = require('try-to-catch');
7
7
  const {
@@ -12,11 +12,18 @@ const {
12
12
  const {isArray} = Array;
13
13
  const maybeArray = (a) => isArray(a) ? a : [a, {}];
14
14
 
15
- module.exports.getFormatter = async (formatterOptional, exit) => {
16
- const [formatterName, formatterOptions] = maybeArray(formatterOptional);
17
- const loadFormatter = createAsyncLoader('formatter');
15
+ module.exports.getFormatter = async (formatterOptional, exit, overrides = {}) => {
16
+ const {
17
+ createAsyncLoader = _createAsyncLoader,
18
+ simpleImport = _simpleImport,
19
+ } = overrides;
18
20
 
19
- const [error, formatter] = await tryToCatch(loadFormatter, formatterName, simpleImport);
21
+ const [formatterName = 'none', formatterOptions] = maybeArray(formatterOptional);
22
+ const loadFormatter = createAsyncLoader('formatter', {
23
+ simpleImport,
24
+ });
25
+
26
+ const [error, formatter] = await tryToCatch(loadFormatter, formatterName);
20
27
 
21
28
  if (formatter)
22
29
  return [formatter, formatterOptions];
package/lib/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import module from 'node:module';
2
2
  import tryCatch from 'try-catch';
3
- import getOptions from 'putout/cli/get-options';
3
+ import _getOptions from 'putout/cli/get-options';
4
4
  import {
5
5
  INTERACTIVE_CANCELED,
6
6
  INVALID_CONFIG,
7
7
  } from 'putout/exit-codes';
8
- import {getFormatter} from './formatter/formatter.cjs';
8
+ import {getFormatter as _getFormatter} from './formatter/formatter.cjs';
9
9
  import Report from './report.cjs';
10
10
 
11
11
  const {createRequire} = module;
@@ -15,7 +15,16 @@ const {dependencies} = require('putout/package.json');
15
15
 
16
16
  const {keys} = Object;
17
17
 
18
- export const createReport = async ({args, cwd, exit}) => {
18
+ export const createReport = async (overrides = {}) => {
19
+ const {
20
+ args,
21
+ cwd,
22
+ exit,
23
+ getOptions = _getOptions,
24
+ cliChooseFormatter = '@putout/cli-choose-formatter',
25
+ getFormatter = _getFormatter,
26
+ } = overrides;
27
+
19
28
  const {interactive, format} = args;
20
29
 
21
30
  const report = Report();
@@ -34,7 +43,7 @@ export const createReport = async ({args, cwd, exit}) => {
34
43
  let newFormatter;
35
44
 
36
45
  if (interactive) {
37
- const {chooseFormatter} = await import('@putout/cli-choose-formatter');
46
+ const {chooseFormatter} = await import(cliChooseFormatter);
38
47
 
39
48
  [newFormatter] = await chooseFormatter(defaultFormatter, keys(dependencies));
40
49
 
package/lib/subscribe.js CHANGED
@@ -1,7 +1,7 @@
1
- import {keypress} from '@putout/cli-keypress';
2
- import {createReport} from './index.js';
1
+ import {keypress as _keypress} from '@putout/cli-keypress';
2
+ import {createReport as _createReport} from './index.js';
3
3
 
4
- export const subscribe = async ({write, cwd, args, worker, exit}) => {
4
+ export const subscribe = async ({write, cwd, args, worker, exit, createReport = _createReport, keypress = _keypress}) => {
5
5
  const {isStop} = keypress();
6
6
  const report = await createReport({
7
7
  args,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/engine-reporter",
3
- "version": "5.0.1",
3
+ "version": "7.0.0",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Run 🐊Putout formatters",
@@ -32,7 +32,7 @@
32
32
  "dependencies": {
33
33
  "@putout/cli-choose-formatter": "^5.0.1",
34
34
  "@putout/cli-keypress": "^3.0.0",
35
- "@putout/engine-loader": "^16.0.0",
35
+ "@putout/engine-loader": "^17.0.0",
36
36
  "fullstore": "^3.0.0",
37
37
  "try-catch": "^3.0.1",
38
38
  "try-to-catch": "^3.0.1"
@@ -45,11 +45,10 @@
45
45
  "@putout/eslint-flat": "^3.0.0",
46
46
  "@putout/formatter-progress": "*",
47
47
  "c8": "^10.0.0",
48
- "eslint": "^9.0.0",
48
+ "eslint": "^10.0.0-alpha.0",
49
49
  "eslint-plugin-n": "^17.0.0",
50
- "eslint-plugin-putout": "^28.0.0",
50
+ "eslint-plugin-putout": "^29.0.0",
51
51
  "madrun": "^11.0.0",
52
- "mock-require": "^3.0.3",
53
52
  "montag": "^1.0.0",
54
53
  "nodemon": "^3.0.1",
55
54
  "supertape": "^11.0.3"