refactor: minor code cleanups

This commit is contained in:
Carlos Valente
2024-06-23 21:50:40 +02:00
committed by Carlos Valente
parent 0335da9786
commit 20503de6fd
7 changed files with 32 additions and 28 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ export function consoleSuccess(message: string) {
/**
* Utility function to log messages in red
*/
export function consoleRed(message: string) {
export function consoleError(message: string) {
console.error(inRed(message));
}
+4 -1
View File
@@ -6,6 +6,7 @@ import { get } from '../services/rundown-service/rundownCache.js';
import { getState } from '../stores/runtimeState.js';
import { resolveCrashReportDirectory } from '../setup/index.js';
import { ensureDirectory } from './fileManagement.js';
/**
* Writes a file to the crash report location
* @param fileName
@@ -13,10 +14,12 @@ import { resolveCrashReportDirectory } from '../setup/index.js';
*/
function writeToFile(fileName: string, content: object) {
const path = join(resolveCrashReportDirectory, fileName);
ensureDirectory(resolveCrashReportDirectory);
try {
const textContent = JSON.stringify(content, null, 2);
writeFileSync(path, textContent);
} catch (e_rror) {
} catch (_) {
/** We do not handle the error here */
}
}
+9
View File
@@ -1,6 +1,7 @@
import multer from 'multer';
import path from 'path';
import fs from 'fs';
import { rm } from 'fs/promises';
import { ensureDirectory } from './fileManagement.js';
import { getAppDataPath, uploadsFolderPath } from '../setup/index.js';
@@ -56,3 +57,11 @@ export const storage = multer.diskStorage({
cb(null, file.originalname);
},
});
export async function clearUploadfolder() {
try {
await rm(uploadsFolderPath, { recursive: true });
} catch (_) {
//we dont care that there was no folder
}
}