Skip to content

Commit bcc663c

Browse files
authored
feat: add warn type to global context.logger (#3423)
* add `warn` type to logger in `getLogger` * test: update test case `'Expose "error", "success" and "log" functions'` * type: add `warn` to `logger` type interface * doc: add available logger function to docs * type: update type interface doc for `logger`
1 parent 8002f72 commit bcc663c

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

docs/developer-guide/plugin.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ if (env.GITHUB_TOKEN) {
241241

242242
## Logger
243243

244-
Use `context.logger` to provide debug logging in the plugin.
244+
Use `context.logger` to provide debug logging in the plugin. Available logging functions: `log`, `warn`, `success`, `error`.
245245

246246
```js
247247
const { logger } = context;

index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ declare module "semantic-release" {
3838
/**
3939
* Signale console loger instance.
4040
*
41-
* Has error, log and success methods.
41+
* Has error, log, warn and success methods.
4242
*/
43-
logger: Signale<"error" | "log" | "success">;
43+
logger: Signale<"error" | "log" | "success" | "warn">;
4444
}
4545

4646
/**

lib/get-logger.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ export default ({ stdout, stderr }) =>
1414
error: { badge: figures.cross, color: "red", label: "", stream: [stderr] },
1515
log: { badge: figures.info, color: "magenta", label: "", stream: [stdout] },
1616
success: { badge: figures.tick, color: "green", label: "", stream: [stdout] },
17+
warn: { badge: figures.warning, color: "yellow", label: "", stream: [stderr] },
1718
},
1819
});

test/get-logger.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@ import test from "ava";
22
import { spy } from "sinon";
33
import getLogger from "../lib/get-logger.js";
44

5-
test('Expose "error", "success" and "log" functions', (t) => {
5+
test('Expose "error", "success", warn and "log" functions', (t) => {
66
const stdout = spy();
77
const stderr = spy();
88
const logger = getLogger({ stdout: { write: stdout }, stderr: { write: stderr } });
99

1010
logger.log("test log");
1111
logger.success("test success");
1212
logger.error("test error");
13+
logger.warn("test warn");
1314

1415
t.regex(stdout.args[0][0], /.*test log/);
1516
t.regex(stdout.args[1][0], /.*test success/);
1617
t.regex(stderr.args[0][0], /.*test error/);
18+
t.regex(stderr.args[1][0], /.*test warn/);
1719
});

0 commit comments

Comments
 (0)