Refactor key generation logic and add option to disable key generation
This commit is contained in:
7
index.js
7
index.js
@@ -18,6 +18,8 @@ require("dotenv").config()
|
|||||||
const GIT_URI = process.env.GIT_URI
|
const GIT_URI = process.env.GIT_URI
|
||||||
const GIT_BRANCH = process.env.GIT_BRANCH || "main"
|
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 PROJECT_DIR = resolvePath(__dirname + "\\project")
|
||||||
|
|
||||||
const KEY_DIR = resolvePath(__dirname + "\\keys")
|
const KEY_DIR = resolvePath(__dirname + "\\keys")
|
||||||
@@ -51,6 +53,11 @@ async function tryGenerateKeys() {
|
|||||||
console.log("no need to generate key, already exists")
|
console.log("no need to generate key, already exists")
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!shouldGenerateKeys) {
|
||||||
|
console.log("shouldGenerateKeys is false, skipping key generation")
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log("Generating keys...")
|
||||||
const aPromise = new Promise(function(resolve, reject) {
|
const aPromise = new Promise(function(resolve, reject) {
|
||||||
keygen({
|
keygen({
|
||||||
location: KEY_LOCATION,
|
location: KEY_LOCATION,
|
||||||
|
|||||||
Reference in New Issue
Block a user