From 7e6cc7bb329f50fd06513a008ea20313e24528e6 Mon Sep 17 00:00:00 2001 From: cupcakearmy Date: Sun, 29 Nov 2020 15:27:32 +0100 Subject: [PATCH] lock only if config required --- src/index.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/index.ts b/src/index.ts index 4879376..1aa58dd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -115,21 +115,23 @@ if (ci) colors.disable() async function main() { try { - const lock = readLock() - if (lock.running) throw new Error('An instance of autorestic is already running for this config file'.red) + if (requireConfig) { + config = init(configFile) + const lock = readLock() + if (lock.running) throw new Error('An instance of autorestic is already running for this config file'.red) - writeLock({ - ...lock, - running: true, - }) + writeLock({ + ...lock, + running: true, + }) + } - if (requireConfig) config = init(configFile) await queue() if (error) process.exit(1) } catch (e) { console.error(e.message) } finally { - unlock() + if (requireConfig) unlock() } } main()