Refactor key generation logic and add option to disable key generation

This commit is contained in:
Aaro Varis
2024-09-23 11:52:44 +03:00
parent 0ba61fe0bf
commit 95ada97b2f

View File

@@ -18,6 +18,8 @@ require("dotenv").config()
const GIT_URI = process.env.GIT_URI
const GIT_BRANCH = process.env.GIT_BRANCH || "main"
const shouldGenerateKeys = process.env.GENERATE_KEYS || GIT_URI.startsWith("ssh://") || false
const PROJECT_DIR = resolvePath(__dirname + "\\project")
const KEY_DIR = resolvePath(__dirname + "\\keys")
@@ -51,6 +53,11 @@ async function tryGenerateKeys() {
console.log("no need to generate key, already exists")
return;
}
if (!shouldGenerateKeys) {
console.log("shouldGenerateKeys is false, skipping key generation")
return;
}
console.log("Generating keys...")
const aPromise = new Promise(function(resolve, reject) {
keygen({
location: KEY_LOCATION,