Skip to content

Commit d06e927

Browse files
committed
fix: github actions fn mapping
1 parent d50a727 commit d06e927

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/logger/__tests__/transports/github.test.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('github', () => {
2525

2626
strictEqual(process.stdout.write.mock.callCount(), 1);
2727
deepStrictEqual(callsArgs, [
28-
'::notice ::[21:00:00.000] \x1B[34mDEBUG\x1B[39m: Test message\n',
28+
'::debug::[21:00:00.000] \x1B[34mDEBUG\x1B[39m: Test message\n',
2929
]);
3030
});
3131

@@ -72,7 +72,7 @@ describe('github', () => {
7272

7373
strictEqual(process.stdout.write.mock.callCount(), 1);
7474
deepStrictEqual(callsArgs, [
75-
'::notice ::[21:00:00.000] \x1B[35mERROR\x1B[39m: Test message\n',
75+
'::error ::[21:00:00.000] \x1B[35mERROR\x1B[39m: Test message\n',
7676
]);
7777
});
7878

@@ -96,7 +96,7 @@ describe('github', () => {
9696

9797
strictEqual(process.stdout.write.mock.callCount(), 1);
9898
deepStrictEqual(callsArgs, [
99-
'::notice ::[21:00:00.000] \x1B[31mFATAL\x1B[39m: Test message\n',
99+
'::error ::[21:00:00.000] \x1B[31mFATAL\x1B[39m: Test message\n',
100100
]);
101101
});
102102

src/logger/transports/github.mjs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22

33
import * as core from '@actions/core';
44

5+
import { LogLevel } from '../constants.mjs';
56
import { prettifyLevel } from '../utils/colors.mjs';
67
import { prettifyTimestamp } from '../utils/time.mjs';
78

89
const actions = {
9-
debug: core.debug,
10-
info: core.notice,
11-
warn: core.warning,
12-
error: core.error,
13-
fatal: core.error,
10+
[LogLevel.debug]: core.debug,
11+
[LogLevel.info]: core.notice,
12+
[LogLevel.warn]: core.warning,
13+
[LogLevel.error]: core.error,
14+
[LogLevel.fatal]: core.error,
1415
};
1516

1617
/**
@@ -35,7 +36,7 @@ export const github = ({
3536

3637
const logMessage = `[${time}] ${prettyLevel}${module ? ` (${module})` : ''}: ${message}`;
3738

38-
const logFn = actions[level] || core.notice;
39+
const logFn = actions[level] ?? core.notice;
3940

4041
logFn(logMessage, {
4142
file: file?.path,

0 commit comments

Comments
 (0)