From b0348aba54ce5913bc8dab7a0ec6d35377d4d5c6 Mon Sep 17 00:00:00 2001 From: Florian Date: Mon, 5 Aug 2024 07:05:56 +0200 Subject: [PATCH] fix: moved & renamed `skipInfoValidation` --- index.js | 13 ++++--------- lib/mod-info.js | 13 ++++++++++--- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/index.js b/index.js index a801917..6291634 100644 --- a/index.js +++ b/index.js @@ -17,14 +17,9 @@ async function verifyConditions(config, context) { const { logger } = context; const errors = []; - const { skip_validation } = config; - try { const info = await readInfoFile(config, context); - - if (skip_validation == undefined) { - isInfoValid(config, context, info); - } + isInfoValid(config, context, info); await verifyToken(config, context, info.name); } catch (error) { @@ -46,7 +41,7 @@ async function prepare(config, context) { } catch (error) { errors.push(error); } - + if (errors.length > 0) { throw new AggregateError(errors); } @@ -61,7 +56,7 @@ async function publish(config, context) { const archiveFile = [info.name, "_", info.version, ".zip"].join(""); const archiveCommand = "git archive --format zip --prefix " + info.name + - "/ --worktree-attributes --output " + archiveFile + " HEAD"; + "/ --worktree-attributes --output " + archiveFile + " HEAD"; logger.log("packaging mod for release"); const { stdout0, stderr0 } = await exec(archiveCommand); @@ -70,7 +65,7 @@ async function publish(config, context) { } catch (error) { errors.push(error); } - + if (errors.length > 0) { throw new AggregateError(errors); } diff --git a/lib/mod-info.js b/lib/mod-info.js index 22844d0..6c8ccdb 100644 --- a/lib/mod-info.js +++ b/lib/mod-info.js @@ -14,7 +14,7 @@ function getInfoFilePath(config, context) { async function readInfoFile(config, context) { try { const result = await readFile(getInfoFilePath(config, context), "utf-8"); - + return JSON.parse(result); } catch (error) { throw getMiscError(error); @@ -30,6 +30,13 @@ async function writeInfoFile(config, context, info_file_obj) { } function isInfoValid(config, context, info_file_obj) { + const { skipInfoValidation } = config; + + if (skipInfoValidation) { + context.logger.log("skipping info.json validation"); + return true; + } + const { logger } = context; try { @@ -37,7 +44,7 @@ function isInfoValid(config, context, info_file_obj) { var v = new Validator(); var res = v.validate(info_file_obj, infoSchema); - + if (res.valid) { logger.log("info.json is valid"); return true; @@ -58,7 +65,7 @@ async function updateInfo(config, context) { var info = await readInfoFile(config, context); info.version = context.nextRelease.version; - + await writeInfoFile(config, context, info); } catch (error) { throw getMiscError(error);