Skip to content

Commit 48492ec

Browse files
committed
fix: @putout/cli-process-file: log error
1 parent f69c01e commit 48492ec

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

packages/cli-process-file/lib/process-file.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module.exports = ({fix, fixCount, logError, raw}) => async function processFile(
3838
printer: configurePrinter(name, printer),
3939
});
4040

41-
raw && logError(e);
41+
e && raw && logError(e);
4242

4343
if (!again && e && e.reason === 'parse') {
4444
const {lint} = await simpleImport('samadhi');

packages/cli-process-file/lib/process-file.spec.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,3 +1054,21 @@ test('putout: cli: process-file: logError: traverse', async (t) => {
10541054
t.calledWith(logError, [error], 'should call logError');
10551055
t.end();
10561056
});
1057+
1058+
test('putout: cli: process-file: logError: traverse: no error', async (t) => {
1059+
const logError = stub();
1060+
const lint = processFile({
1061+
raw: true,
1062+
logError,
1063+
fix: true,
1064+
});
1065+
1066+
const source = 'const a = 2';
1067+
1068+
await lint({
1069+
source,
1070+
});
1071+
1072+
t.notCalled(logError);
1073+
t.end();
1074+
});

0 commit comments

Comments
 (0)