From 1fc1ea124bbbc9bcb9cc5cad8f5101baa0be6fcf Mon Sep 17 00:00:00 2001 From: Himanshu Sharma Date: Fri, 29 Mar 2024 05:05:56 +0530 Subject: [PATCH] logger issue fixed --- package-lock.json | 3 +-- src/utils/autoDeploy.ts | 10 +++------- src/utils/logger.ts | 5 +++-- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6af8dbf..85ba3e3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4050,8 +4050,7 @@ "version": "5.3.1", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.1.tgz", "integrity": "sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng==", - "dev": true, - "requires": {} + "dev": true }, "ajv": { "version": "6.12.6", diff --git a/src/utils/autoDeploy.ts b/src/utils/autoDeploy.ts index 364fd4d..e44851a 100644 --- a/src/utils/autoDeploy.ts +++ b/src/utils/autoDeploy.ts @@ -9,7 +9,7 @@ import { currentFile, protocol } from '../constants'; -import { isIAllApps } from './utils'; +import { isIAllApps, logProcessOutput } from './utils'; export const findJsonFilesRecursively = async ( appsDir: string @@ -36,12 +36,8 @@ export const findJsonFilesRecursively = async ( currentFile }); - proc.stdout?.on('data', (data: Buffer) => { - console.log(data.toString().green); - }); - proc.stderr?.on('data', (data: Buffer) => { - console.log(data.toString().red); - }); + logProcessOutput(proc.stdout, 'green'); + logProcessOutput(proc.stderr, 'red'); proc.on('message', (data: childProcessResponse) => { if (data.type === protocol.g) { diff --git a/src/utils/logger.ts b/src/utils/logger.ts index 9732acf..43cb614 100644 --- a/src/utils/logger.ts +++ b/src/utils/logger.ts @@ -10,8 +10,9 @@ export const logger = { const timeStamp = new Date().toISOString(); const logMessage = `${timeStamp} - ${message}\n`; console.log(message); - if (!fs.existsSync(logFileFullPath)) { - fs.writeFileSync(logFileFullPath, '', { encoding: 'utf-8' }); + + if (!fs.existsSync(logFilePath)) { + fs.mkdirSync(logFilePath, { recursive: true }); } fs.appendFileSync(logFileFullPath, logMessage, { encoding: 'utf-8' }); }