mirror of
https://github.com/cupcakearmy/autorestic.git
synced 2024-12-22 16:26:25 +00:00
notify user if config file was overwritten and make a copy of it as backup
This commit is contained in:
parent
bc36a39de4
commit
7e577c439a
@ -1,4 +1,3 @@
|
||||
## 0.15
|
||||
## 0.16
|
||||
|
||||
- automatic binary releases
|
||||
- code signing
|
||||
- notify user if config file was overwritten and make a copy of it as backup
|
@ -25,7 +25,7 @@ export const { _: commands, ...flags } = minimist(process.argv.slice(2), {
|
||||
string: ['l', 'b'],
|
||||
})
|
||||
|
||||
export const VERSION = '0.14'
|
||||
export const VERSION = '0.16'
|
||||
export const INSTALL_DIR = '/usr/local/bin'
|
||||
export const VERBOSE = flags.verbose
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { readFileSync, writeFileSync, statSync } from 'fs'
|
||||
import { readFileSync, writeFileSync, statSync, copyFileSync } from 'fs'
|
||||
import { resolve } from 'path'
|
||||
import { homedir } from 'os'
|
||||
|
||||
@ -88,10 +88,27 @@ export const init = (): Config | undefined => {
|
||||
yaml.safeLoad(readFileSync(CONFIG_FILE).toString()),
|
||||
)
|
||||
|
||||
const current = JSON.stringify(raw)
|
||||
|
||||
normalizeAndCheckBackends(raw)
|
||||
normalizeAndCheckBackups(raw)
|
||||
|
||||
const changed = JSON.stringify(raw) !== current
|
||||
|
||||
if (changed) {
|
||||
const OLD_CONFIG_FILE = CONFIG_FILE + '.old'
|
||||
copyFileSync(CONFIG_FILE, OLD_CONFIG_FILE)
|
||||
writeFileSync(CONFIG_FILE, yaml.safeDump(raw))
|
||||
console.log(
|
||||
'\n' +
|
||||
'⚠️ MOVED OLD CONFIG FILE TO: ⚠️'.red.underline.bold +
|
||||
'\n' +
|
||||
OLD_CONFIG_FILE +
|
||||
'\n' +
|
||||
'What? Why? '.grey + 'https://git.io/Jv2D0'.underline.grey +
|
||||
'\n'
|
||||
)
|
||||
}
|
||||
|
||||
return raw
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user