Skip to content

Commit bf9b31c

Browse files
committed
feature: @putout/engine-reporter: do not exit when plugins
1 parent 27a2811 commit bf9b31c

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

packages/engine-reporter/lib/formatter/formatter.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const {isArray} = Array;
1313
const maybeArray = (a) => isArray(a) ? a : [a, {}];
1414

1515
module.exports.getFormatter = async (formatterOptional, exit) => {
16-
const [formatterName, formatterOptions] = maybeArray(formatterOptional);
16+
const [formatterName = 'none', formatterOptions] = maybeArray(formatterOptional);
1717
const loadFormatter = createAsyncLoader('formatter');
1818

1919
const [error, formatter] = await tryToCatch(loadFormatter, formatterName, simpleImport);

packages/engine-reporter/lib/formatter/formatter.spec.cjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const {
99
} = require('putout/exit-codes/cjs');
1010

1111
const {getFormatter} = require('./formatter.cjs');
12+
1213
const {reRequire, stopAll} = mockRequire;
1314

1415
test('putout: cli: formatter: get formatter', async (t) => {
@@ -23,6 +24,17 @@ test('putout: cli: formatter: get formatter', async (t) => {
2324
t.end();
2425
});
2526

27+
test('putout: cli: formatter: get formatter: none', async (t) => {
28+
const exit = stub();
29+
30+
const result = await getFormatter(undefined, exit);
31+
const expected = [
32+
stub(), {}];
33+
34+
t.deepEqual(result, expected);
35+
t.end();
36+
});
37+
2638
test('putout: cli: formatter: get formatter: options', async (t) => {
2739
const exit = stub();
2840

packages/engine-reporter/lib/index.spec.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
} from 'putout/exit-codes';
66
import {createReport} from './index.js';
77

8-
test('putout: engine-reporter: createReport', async (t) => {
8+
test('putout: engine-reporter: createReport: no plugins', async (t) => {
99
const exit = stub();
1010
const cwd = stub();
1111

@@ -15,6 +15,22 @@ test('putout: engine-reporter: createReport', async (t) => {
1515
exit,
1616
});
1717

18+
t.notCalled(exit);
19+
t.end();
20+
});
21+
22+
test('putout: engine-reporter: createReport', async (t) => {
23+
const getOptions = stub().throws(TypeError('plugins is not iterable'));
24+
const cwd = stub();
25+
const exit = stub();
26+
27+
await createReport({
28+
args: [],
29+
cwd,
30+
exit,
31+
getOptions,
32+
});
33+
1834
t.calledWith(exit, [INVALID_CONFIG, TypeError('plugins is not iterable')]);
1935
t.end();
2036
});

0 commit comments

Comments
 (0)