Skip to content

Commit

Permalink
fix: moved & renamed skipInfoValidation
Browse files Browse the repository at this point in the history
  • Loading branch information
fgardt committed Aug 5, 2024
1 parent 8c18daf commit b0348ab
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
13 changes: 4 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -46,7 +41,7 @@ async function prepare(config, context) {
} catch (error) {
errors.push(error);
}

if (errors.length > 0) {
throw new AggregateError(errors);
}
Expand All @@ -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);
Expand All @@ -70,7 +65,7 @@ async function publish(config, context) {
} catch (error) {
errors.push(error);
}

if (errors.length > 0) {
throw new AggregateError(errors);
}
Expand Down
13 changes: 10 additions & 3 deletions lib/mod-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -30,14 +30,21 @@ 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 {
logger.log("validating mod info.json");

var v = new Validator();
var res = v.validate(info_file_obj, infoSchema);

if (res.valid) {
logger.log("info.json is valid");
return true;
Expand All @@ -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);
Expand Down

0 comments on commit b0348ab

Please sign in to comment.