now shows elapsed time on each backup and some depulication of code

This commit is contained in:
cupcakearmy
2019-12-10 13:44:30 +01:00
parent f09cf90653
commit 5b0011330c
4 changed files with 67 additions and 7 deletions

View File

@@ -3,12 +3,21 @@ import { Writer } from 'clitastic'
import { config, VERBOSE } from './autorestic'
import { getEnvFromBackend } from './backend'
import { Locations, Location } from './types'
import { exec, ConfigError, pathRelativeToConfigFile, getFlagsFromLocation, makeArrayIfIsNot, execPlain } from './utils'
import {
exec,
ConfigError,
pathRelativeToConfigFile,
getFlagsFromLocation,
makeArrayIfIsNot,
execPlain,
MeasureDuration, fill,
} from './utils'
export const backupSingle = (name: string, to: string, location: Location) => {
if (!config) throw ConfigError
const delta = new MeasureDuration()
const writer = new Writer(name + to.blue + ' : ' + 'Backing up... ⏳')
const backend = config.backends[to]
@@ -21,12 +30,12 @@ export const backupSingle = (name: string, to: string, location: Location) => {
)
if (VERBOSE) console.log(cmd.out, cmd.err)
writer.done(name + to.blue + ' : ' + 'Done ✓'.green)
writer.done(`${name}${to.blue} : ${'Done ✓'.green} (${delta.finished(true)})`)
}
export const backupLocation = (name: string, location: Location) => {
const display = name.yellow + ' ▶ '
const filler = new Array(name.length + 3).fill(' ').join('')
const filler = fill(name.length + 3)
let first = true
if (location.hooks && location.hooks.before)