mirror of
https://github.com/cupcakearmy/autorestic.git
synced 2024-12-22 08:16:25 +00:00
version as normal command
This commit is contained in:
parent
de27034b94
commit
47f5d91e89
@ -27,11 +27,6 @@ export const VERSION = '0.5'
|
|||||||
export const INSTALL_DIR = '/usr/local/bin'
|
export const INSTALL_DIR = '/usr/local/bin'
|
||||||
export const VERBOSE = flags.verbose
|
export const VERBOSE = flags.verbose
|
||||||
|
|
||||||
if (flags.version) {
|
|
||||||
console.log('version'.grey, VERSION)
|
|
||||||
process.exit(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
export const config = init()
|
export const config = init()
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
|
@ -51,7 +51,7 @@ export const normalizeAndCheckBackups = (config: Config) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const findConfigFile = (): string => {
|
const findConfigFile = (): string | undefined => {
|
||||||
const config = '.autorestic.yml'
|
const config = '.autorestic.yml'
|
||||||
const paths = [
|
const paths = [
|
||||||
resolve(flags.config || ''),
|
resolve(flags.config || ''),
|
||||||
@ -64,17 +64,14 @@ const findConfigFile = (): string => {
|
|||||||
if (file.isFile()) return path
|
if (file.isFile()) return path
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
throw new Error('No Config file found')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export let CONFIG_FILE: string = ''
|
export let CONFIG_FILE: string = ''
|
||||||
|
|
||||||
export const init = (): Config | undefined => {
|
export const init = (): Config | undefined => {
|
||||||
try {
|
const file = findConfigFile()
|
||||||
CONFIG_FILE = findConfigFile()
|
if (file) CONFIG_FILE = file
|
||||||
} catch (e) {
|
else return
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const raw: Config = makeObjectKeysLowercase(
|
const raw: Config = makeObjectKeysLowercase(
|
||||||
yaml.safeLoad(readFileSync(CONFIG_FILE).toString())
|
yaml.safeLoad(readFileSync(CONFIG_FILE).toString())
|
||||||
|
@ -203,6 +203,9 @@ const handlers: Handlers = {
|
|||||||
|
|
||||||
w.done('All up to date! 🚀')
|
w.done('All up to date! 🚀')
|
||||||
},
|
},
|
||||||
|
version() {
|
||||||
|
console.log('version'.grey, VERSION)
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export const help = () => {
|
export const help = () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user