Files
certd/packages/core/basic/src/utils/util.file.ts
T

17 lines
360 B
TypeScript
Raw Normal View History

2024-10-15 13:11:40 +08:00
import fs from 'fs';
2023-06-25 23:25:56 +08:00
function getFileRootDir(rootDir?: string) {
if (rootDir == null) {
const userHome = process.env.HOME || process.env.USERPROFILE;
2024-10-15 13:11:40 +08:00
rootDir = userHome + '/.certd/storage/';
2023-06-25 23:25:56 +08:00
}
if (!fs.existsSync(rootDir)) {
fs.mkdirSync(rootDir, { recursive: true });
}
return rootDir;
}
export const fileUtils = {
getFileRootDir,
};