Skip to content

Commit

Permalink
Try to fix description parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
EricKotato committed May 26, 2020
1 parent e4c2b53 commit 1d7895f
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions scripts/option_parser.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
module.exports = ({github, context}) => {
function parseDescription(s) {
let pattern = /(?:((?:.|\n)*?)\n\n)/g;
let matches = pattern.exec(s);
if (!matches) return "";

let result = "";

while (matches != null) {
if (result) {
result += "\n\n";
}

result += matches[1];
}

return result;
}

function parseBoolOption(s, namePattern) {
let pattern = /^([a-z ]+):\s*(yes|no|true|false|enabled?|disabled?|on|off|0|1)$/gmi;
let matches = pattern.exec(s);
Expand Down Expand Up @@ -102,13 +120,12 @@ module.exports = ({github, context}) => {
console.log(context.payload.release.body);

let descriptionArray = context.payload.release.body.trim().split("\n\n");
let [description, params] = ["", ""];
let params = "";

if (descriptionArray.length == 1) {
params = descriptionArray[0].trim();
} else if (descriptionArray.length >= 2) {
params = descriptionArray.pop().trim();
description = descriptionArray.join("\n\n").trim();
}

let requestParams = {
Expand All @@ -119,7 +136,7 @@ module.exports = ({github, context}) => {
packer: parsePacker(params),
telegram: parseTelegramUploader(params),
installer: parseInstaller(params),
description: description,
description: parseDescription(context.payload.release.body),
};

console.log("Parsed parameters:");
Expand Down

0 comments on commit 1d7895f

Please sign in to comment.