From 6c6ca18f98f20fce352026bb9f182a47471946b2 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 30 Jul 2021 15:40:39 +0100 Subject: [PATCH] Fixing worker dev script to not overwrite env file everytime. --- packages/worker/scripts/dev/manage.js | 40 ++++++++++++++------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/packages/worker/scripts/dev/manage.js b/packages/worker/scripts/dev/manage.js index 682c28feae..281c677ed7 100644 --- a/packages/worker/scripts/dev/manage.js +++ b/packages/worker/scripts/dev/manage.js @@ -4,26 +4,28 @@ const fs = require("fs") async function init() { const envFilePath = path.join(process.cwd(), ".env") - const envFileJson = { - SELF_HOSTED: 1, - PORT: 4002, - CLUSTER_PORT: 10000, - JWT_SECRET: "testsecret", - INTERNAL_API_KEY: "budibase", - MINIO_ACCESS_KEY: "budibase", - MINIO_SECRET_KEY: "budibase", - REDIS_URL: "localhost:6379", - REDIS_PASSWORD: "budibase", - MINIO_URL: "http://localhost:10000/", - COUCH_DB_URL: "http://budibase:budibase@localhost:10000/db/", - // empty string is false - MULTI_TENANCY: "", + if (!fs.existsSync(envFilePath)) { + const envFileJson = { + SELF_HOSTED: 1, + PORT: 4002, + CLUSTER_PORT: 10000, + JWT_SECRET: "testsecret", + INTERNAL_API_KEY: "budibase", + MINIO_ACCESS_KEY: "budibase", + MINIO_SECRET_KEY: "budibase", + REDIS_URL: "localhost:6379", + REDIS_PASSWORD: "budibase", + MINIO_URL: "http://localhost:10000/", + COUCH_DB_URL: "http://budibase:budibase@localhost:10000/db/", + // empty string is false + MULTI_TENANCY: "", + } + let envFile = "" + Object.keys(envFileJson).forEach(key => { + envFile += `${key}=${envFileJson[key]}\n` + }) + fs.writeFileSync(envFilePath, envFile) } - let envFile = "" - Object.keys(envFileJson).forEach(key => { - envFile += `${key}=${envFileJson[key]}\n` - }) - fs.writeFileSync(envFilePath, envFile) } // if more than init required use this to determine the command type