From 42b66e6200c52f2d62d1ca6a76b0440405e2964b Mon Sep 17 00:00:00 2001 From: yoshinorin Date: Sat, 5 Nov 2022 01:13:58 +0900 Subject: [PATCH] fix: `Options` argument from required to optional (#132) --- README.md | 9 +++++++++ lib/log.ts | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b2ae2ae..fe911d7 100644 --- a/README.md +++ b/README.md @@ -20,13 +20,22 @@ const log = require('hexo-log')({ debug: false, silent: false }); +log.info('Hello world'); // v4.x.x const log = require('hexo-log').default({ debug: false, silent: false }); +log.info('Hello world'); + +// v4.x.x (ES Module) +import { logger } from 'hexo-log'; +const log = logger({ + debug: false, + silent: false +}); log.info('Hello world'); ``` diff --git a/lib/log.ts b/lib/log.ts index ba33870..e448573 100644 --- a/lib/log.ts +++ b/lib/log.ts @@ -149,7 +149,7 @@ class Logger { } } -export default function createLogger(options: Options) { +export default function createLogger(options: Options = {}) { const logger = new Logger(options); logger.d = logger.debug; @@ -161,4 +161,4 @@ export default function createLogger(options: Options) { return logger; } -export const logger = (option: Options) => createLogger(option); +export const logger = (option: Options = {}) => createLogger(option);