use find and remove unneccessary checks
This commit is contained in:
@@ -114,11 +114,14 @@ export class DbConfigStore extends DisposableObject {
|
||||
|
||||
const config: DbConfig = cloneDbConfig(this.config);
|
||||
if (parentList) {
|
||||
config.databases.remote.repositoryLists.forEach((list) => {
|
||||
if (list.name === parentList) {
|
||||
list.repositories.push(repoNwo);
|
||||
const parent = config.databases.remote.repositoryLists.find(
|
||||
(list) => list.name === parentList,
|
||||
);
|
||||
if (!parent) {
|
||||
throw Error(`Cannot find parent list '${parentList}'`);
|
||||
} else {
|
||||
parent.repositories.push(repoNwo);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
config.databases.remote.repositories.push(repoNwo);
|
||||
}
|
||||
|
||||
@@ -79,13 +79,6 @@ export class DbManager {
|
||||
nwo: string,
|
||||
parentList?: string,
|
||||
): Promise<void> {
|
||||
if (nwo === "") {
|
||||
throw new Error("Repository name cannot be empty");
|
||||
}
|
||||
if (this.dbConfigStore.doesRemoteDbExist(nwo)) {
|
||||
throw new Error(`The repository '${nwo}' already exists`);
|
||||
}
|
||||
|
||||
await this.dbConfigStore.addRemoteRepo(nwo, parentList);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user