refactor: create repo.json if not exist

This commit is contained in:
Ravinou 2025-03-28 17:58:22 +01:00
commit 8b4ca5d7bc
No known key found for this signature in database
GPG key ID: EEEE670C40F6A4D7

View file

@ -28,6 +28,13 @@ export const updateUsersList = async (usersList: BorgWarehouseUser[]): Promise<v
};
export const getRepoList = async (): Promise<Repository[]> => {
try {
await fs.access(repoFilePath);
} catch {
console.log('repo.json not found, creating a new one.');
await fs.writeFile(repoFilePath, JSON.stringify([]));
}
try {
const fileContent = await fs.readFile(repoFilePath, 'utf8');
return JSON.parse(fileContent) || [];