From 9ec53ed4331dd9aa174a1e6281e40a4ab5cb2fd7 Mon Sep 17 00:00:00 2001 From: Alexis Tyler Date: Wed, 21 Apr 2021 19:14:57 +0930 Subject: [PATCH] fix: switch-env not detecting env --- app/cli.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/cli.ts b/app/cli.ts index 1fb8ad581..ca7f4e958 100644 --- a/app/cli.ts +++ b/app/cli.ts @@ -177,10 +177,10 @@ const commands = { }, async 'switch-env'() { const envFile = await fs.promises.readFile('/boot/config/plugins/Unraid.net/env', 'utf-8').catch(() => ''); - // Match the env file env="production" which would be [1] = env and [2] = production + // Match the env file env="production" which would be [0] = env="production", [1] = env and [2] = production const matchArray = /([a-zA-Z]+)=["]*([a-zA-Z]+)["]*/.exec(envFile); // Get item from index 2 of the regex match or return undefined - const [,,currentEnv] = matchArray && matchArray.length === 2 ? matchArray : []; + const [,,currentEnv] = matchArray && matchArray.length === 3 ? matchArray : []; // No env is set or file doesn't exist if (!currentEnv) {