From 68d4707a2b1cd411cf46b64e9a763bd0f5b9bdd5 Mon Sep 17 00:00:00 2001 From: Thomas Winkler Date: Tue, 29 Oct 2024 22:25:16 +0100 Subject: [PATCH] Fix init to throw error and stop if config already exists --- src/screenshot/helper.ts | 3 ++- src/screenshot/startup.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/screenshot/helper.ts b/src/screenshot/helper.ts index a8a5ee7..a8e7beb 100644 --- a/src/screenshot/helper.ts +++ b/src/screenshot/helper.ts @@ -13,7 +13,8 @@ export function createInitConfig(baseUrl: string): string { # The title is used to describe the screenshot run title: "My screenshot automation" -# The baseUrl is the Cumulocity base URL and can be overwritten by the command line argument +# The baseUrl is the Cumulocity URL and can be overwritten by the command line argument +# All visit URLs are relative to this baseUrl baseUrl: "${baseUrl}" global: diff --git a/src/screenshot/startup.ts b/src/screenshot/startup.ts index 9d3285a..e046f67 100644 --- a/src/screenshot/startup.ts +++ b/src/screenshot/startup.ts @@ -36,10 +36,10 @@ const log = debug("c8y:c8yscrn:startup"); if (!fs.existsSync(yamlFile)) { fs.writeFileSync(yamlFile, createInitConfig(baseUrl), "utf8"); log(`Config file ${yamlFile} created.`); - return; } else { - log(`Config file ${yamlFile} already exists. Skipping init.`); + throw new Error(`Config file ${yamlFile} already exists.`); } + return; } if (!fs.existsSync(yamlFile)) {