From 3842e4c45b672bab8c89c472d35e96bc098a37b9 Mon Sep 17 00:00:00 2001 From: Pedro Bernardo Date: Sun, 26 Jun 2022 15:40:08 -0300 Subject: [PATCH] feat: add mocks logging messages --- lib/scripts/mock.mjs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/scripts/mock.mjs b/lib/scripts/mock.mjs index 2fb993a..26b7fcb 100644 --- a/lib/scripts/mock.mjs +++ b/lib/scripts/mock.mjs @@ -1,11 +1,17 @@ import fs from 'node:fs' import jsonServer from 'json-server' +import { logger, printMocksHost } from '../logger.mjs' export function mock ({ config }) { const dbExists = fs.existsSync(config.mocks.file) - if (!dbExists) { - console.log(`Can't find the mock JSON config at ${config.mocks.file}`) + if (!dbExists && !config.explicitMocks) return + if (!dbExists && config.explicitMocks) { + logger(`Can't start Mocks Server. The config file at [output] wasn't found`, { + output: config.mocks.file, + level: 'warn', + script: 'mocks' + }) return } @@ -18,6 +24,6 @@ export function mock ({ config }) { server.use(config.mocks.route, router) server.listen(config.mocks.port, () => { - console.log('JSON Server is running') + printMocksHost({ mocks: config.mocks }) }) }