Skip to content
This repository has been archived by the owner on May 19, 2023. It is now read-only.

Commit

Permalink
fix(cli): run only enabled services for precache when using all
Browse files Browse the repository at this point in the history
  • Loading branch information
AuHau committed Jun 8, 2020
1 parent 386e2a4 commit 41c9fe0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/cli/precache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ${formattedServices}`

let servicesToPreCache
try {
servicesToPreCache = validateServices(argv)
servicesToPreCache = validateServices(argv, true)
} catch (e) {
this.error(e.message)
}
Expand Down
7 changes: 6 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,18 @@ export function capitalizeFirstLetter (value: string): string {
return value.charAt(0).toUpperCase() + value.slice(1)
}

export function validateServices (args: string[]): SupportedServices[] {
export function validateServices (args: string[], onlyEnabledForAll = false): SupportedServices[] {
if (args.length === 0) {
throw new Error('You have to specify a service!')
}

if (args.length === 1 && args[0] === 'all') {
if (!onlyEnabledForAll) {
return Object.values(SupportedServices)
}

return Object.values(SupportedServices)
.filter(service => config.get(`${service}.enabled`))
}

for (const service of args) {
Expand Down

0 comments on commit 41c9fe0

Please sign in to comment.