Check input combinations
This commit is contained in:
@@ -49,6 +49,10 @@ export function deleteVersions(input: Input): Observable<boolean> {
|
||||
return throwError('No token found')
|
||||
}
|
||||
|
||||
if (!input.checkInput()) {
|
||||
return throwError('Invalid input combination')
|
||||
}
|
||||
|
||||
if (input.numOldVersionsToDelete <= 0) {
|
||||
console.log(
|
||||
'Number of old versions to delete input is 0 or less, no versions will be deleted'
|
||||
|
||||
38
src/input.ts
38
src/input.ts
@@ -47,23 +47,6 @@ export class Input {
|
||||
this.ignoreVersions = validatedParams.ignoreVersions
|
||||
this.deletePreReleaseVersions = validatedParams.deletePreReleaseVersions
|
||||
this.token = validatedParams.token
|
||||
|
||||
if (
|
||||
this.numOldVersionsToDelete > 1 &&
|
||||
(this.minVersionsToKeep >= 0 || this.deletePreReleaseVersions == 'true')
|
||||
) {
|
||||
throwError('Invalid input combination')
|
||||
}
|
||||
|
||||
if (this.deletePreReleaseVersions === 'true') {
|
||||
this.minVersionsToKeep =
|
||||
this.minVersionsToKeep > 0 ? this.minVersionsToKeep : 0
|
||||
this.ignoreVersions = new RegExp('^(0|[1-9]\\d*)((\\.(0|[1-9]\\d*))*)$')
|
||||
}
|
||||
|
||||
if (this.minVersionsToKeep >= 0) {
|
||||
this.numOldVersionsToDelete = 0
|
||||
}
|
||||
}
|
||||
|
||||
hasOldestVersionQueryInfo(): boolean {
|
||||
@@ -76,4 +59,25 @@ export class Input {
|
||||
this.token
|
||||
)
|
||||
}
|
||||
|
||||
checkInput(): boolean {
|
||||
if (
|
||||
this.numOldVersionsToDelete > 1 &&
|
||||
(this.minVersionsToKeep >= 0 || this.deletePreReleaseVersions === 'true')
|
||||
) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (this.deletePreReleaseVersions === 'true') {
|
||||
this.minVersionsToKeep =
|
||||
this.minVersionsToKeep > 0 ? this.minVersionsToKeep : 0
|
||||
this.ignoreVersions = new RegExp('^(0|[1-9]\\d*)((\\.(0|[1-9]\\d*))*)$')
|
||||
}
|
||||
|
||||
if (this.minVersionsToKeep >= 0) {
|
||||
this.numOldVersionsToDelete = 0
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user