method to get all the backends from a list of locations

This commit is contained in:
cupcakearmy 2019-12-04 20:37:50 +01:00
parent cdf18430b6
commit 88059fe405

View File

@ -1,7 +1,7 @@
import { Writer } from 'clitastic'
import { config, VERBOSE } from './autorestic'
import { Backend, Backends } from './types'
import { Backend, Backends, Locations } from './types'
import { exec, ConfigError } from './utils'
@ -34,6 +34,13 @@ export const getEnvFromBackend = (backend: Backend) => {
}
}
export const getBackendsFromLocations = (locations: Locations): string[] => {
const backends = new Set<string>()
for (const to of Object.values(locations).map(location => location.to))
Array.isArray(to) ? to.forEach(t => backends.add(t)) : backends.add(to)
return Array.from(backends)
}
export const checkAndConfigureBackend = (name: string, backend: Backend) => {
const writer = new Writer(name.blue + ' : ' + 'Configuring... ⏳')
const env = getEnvFromBackend(backend)