always unlock

This commit is contained in:
cupcakearmy 2020-06-25 09:17:20 +02:00
parent e8a8ccccd0
commit ea8bf83799
No known key found for this signature in database
GPG Key ID: D28129AE5654D9D9
1 changed files with 36 additions and 37 deletions

View File

@ -6,7 +6,7 @@ import handlers, { error, help } from './handlers'
import { Config } from './types'
import { readLock, writeLock, unlock } from './lock'
process.on('uncaughtException', err => {
process.on('uncaughtException', (err) => {
console.log(err.message)
unlock()
process.exit(1)
@ -32,7 +32,6 @@ export const VERBOSE = flags.verbose
export let config: Config
async function main() {
config = init()
@ -57,8 +56,8 @@ async function main() {
const fn = handlers[command] || error
await fn(args, flags)
unlock()
}
main().catch((e: Error) => console.error(e.message))
main()
.catch((e: Error) => console.error(e.message))
.finally(unlock)