From 88059fe40505939015cf7b7a3ce06c220b047845 Mon Sep 17 00:00:00 2001 From: cupcakearmy Date: Wed, 4 Dec 2019 20:37:50 +0100 Subject: [PATCH] method to get all the backends from a list of locations --- src/backend.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/backend.ts b/src/backend.ts index 3c33d6a..9c69075 100644 --- a/src/backend.ts +++ b/src/backend.ts @@ -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() + 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)