Refactor PPC to pull out reusable componenets.

This commit is contained in:
Patrick Fic
2025-04-04 09:12:38 -07:00
parent 85fcecf856
commit f3adc76574
17 changed files with 957 additions and 451 deletions

View File

@@ -0,0 +1,21 @@
import log from "electron-log/main";
import fs from "fs";
import path from "path";
import errorTypeCheck from "../../util/errorTypeCheck";
const createdDirectoryIfNotExist = async (dirpath: string) => {
try {
const directoryPath = path.dirname(dirpath);
if (!fs.existsSync(directoryPath)) {
log.info(`Directory does not exist. Creating: ${directoryPath}`);
fs.mkdirSync(directoryPath, { recursive: true });
}
} catch (error) {
log.error("Error creating directory as needed", errorTypeCheck(error));
throw new Error(
"Error creating directory: " + errorTypeCheck(error).message,
);
}
};
export default createdDirectoryIfNotExist;