From 336f44e9dc904c94d9ea76b31af94714923b6650 Mon Sep 17 00:00:00 2001 From: cupcakearmy Date: Wed, 4 Dec 2019 23:35:41 +0100 Subject: [PATCH] simplify for --- src/backup.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/backup.ts b/src/backup.ts index 42f67e5..44929b0 100644 --- a/src/backup.ts +++ b/src/backup.ts @@ -10,8 +10,8 @@ import { exec, ConfigError, pathRelativeToConfigFile, getFlagsFromLocation } fro export const backupSingle = (name: string, to: string, location: Location) => { if (!config) throw ConfigError const writer = new Writer(name + to.blue + ' : ' + 'Backing up... ⏳') - const backend = config.backends[to] + const backend = config.backends[to] const path = pathRelativeToConfigFile(location.from) const cmd = exec( @@ -27,13 +27,12 @@ export const backupSingle = (name: string, to: string, location: Location) => { export const backupLocation = (name: string, location: Location) => { const display = name.yellow + ' ▶ ' const filler = new Array(name.length + 3).fill(' ').join('') - if (Array.isArray(location.to)) { - let first = true - for (const t of location.to) { - backupSingle(first ? display : filler, t, location) - if (first) first = false - } - } else backupSingle(display, location.from, location) + let first = true + + for (const t of Array.isArray(location.to) ? location.to : [location.to]) { + backupSingle(first ? display : filler, t, location) + if (first) first = false + } } export const backupAll = (locations?: Locations) => {