mirror of
https://github.com/Ravinou/borgwarehouse
synced 2026-03-14 14:25:46 +01:00
refactor: ⚡ create repo.json if not exist
This commit is contained in:
parent
2316fb573e
commit
8b4ca5d7bc
1 changed files with 7 additions and 0 deletions
|
|
@ -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) || [];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue