Skip to content

Commit

Permalink
logger issue fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
HeeManSu committed Mar 28, 2024
1 parent d3d9d45 commit 1fc1ea1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
3 changes: 1 addition & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 3 additions & 7 deletions src/utils/autoDeploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
currentFile,
protocol
} from '../constants';
import { isIAllApps } from './utils';
import { isIAllApps, logProcessOutput } from './utils';

export const findJsonFilesRecursively = async (
appsDir: string
Expand All @@ -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) {
Expand Down
5 changes: 3 additions & 2 deletions src/utils/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
}
Expand Down

0 comments on commit 1fc1ea1

Please sign in to comment.