From a8af085d9c1349754f63950917b133ab0f26a918 Mon Sep 17 00:00:00 2001 From: cupcakearmy Date: Wed, 8 Jan 2020 00:22:49 +0100 Subject: [PATCH] dont' get stuck if backend is not supported --- src/backend.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/backend.ts b/src/backend.ts index 605e7fc..4c3a9aa 100644 --- a/src/backend.ts +++ b/src/backend.ts @@ -43,16 +43,20 @@ export const getBackendsFromLocations = (locations: Locations): string[] => { export const checkAndConfigureBackend = (name: string, backend: Backend) => { const writer = new Writer(name.blue + ' : ' + 'Configuring... ⏳') - const env = getEnvFromBackend(backend) + try { + const env = getEnvFromBackend(backend) - const { out, err } = exec('restic', ['init'], { env }) + const { out, err } = exec('restic', ['init'], { env }) - if (err.length > 0 && !ALREADY_EXISTS.test(err)) - throw new Error(`Could not load the backend "${name}": ${err}`) + if (err.length > 0 && !ALREADY_EXISTS.test(err)) + throw new Error(`Could not load the backend "${name}": ${err}`) - if (VERBOSE && out.length > 0) console.log(out) + if (VERBOSE && out.length > 0) console.log(out) - writer.done(name.blue + ' : ' + 'Done ✓'.green) + writer.done(name.blue + ' : ' + 'Done ✓'.green) + } catch (e) { + writer.done(name.blue + ' : ' + 'Error ⚠️ ' + e.message.red) + } } export const checkAndConfigureBackends = (backends?: Backends) => {