From: AJ ONeal Date: Mon, 26 Apr 2021 07:20:10 +0000 (+0000) Subject: bugfix: allow whitespace before template vars X-Git-Url: https://git.josue.xyz/?a=commitdiff_plain;h=170a124b0eea64435c8e5814d90a2df3c02b7e95;p=webi-installers%2F.git bugfix: allow whitespace before template vars --- diff --git a/_webi/releases.js b/_webi/releases.js index c7b0b51..31f3b59 100644 --- a/_webi/releases.js +++ b/_webi/releases.js @@ -48,13 +48,19 @@ Releases.renderBash = function ( .then(function (tplTxt) { return ( tplTxt - .replace(/^#?WEBI_PKG=.*/m, "WEBI_PKG='" + pkg + '@' + ver + "'") - .replace(/^#?WEBI_HOST=.*/m, "WEBI_HOST='" + baseurl + "'") - .replace(/^#?WEBI_OS=.*/m, "WEBI_OS='" + (os || '') + "'") - .replace(/^#?WEBI_ARCH=.*/m, "WEBI_ARCH='" + (arch || '') + "'") - .replace(/^#?WEBI_TAG=.*/m, "WEBI_TAG='" + tag + "'") .replace( - /^#?WEBI_RELEASES=.*/m, + /^\s*#?WEBI_PKG=.*/m, + "WEBI_PKG='" + pkg + '@' + ver + "'" + ) + .replace(/^\s*#?WEBI_HOST=.*/m, "WEBI_HOST='" + baseurl + "'") + .replace(/^\s*#?WEBI_OS=.*/m, "WEBI_OS='" + (os || '') + "'") + .replace( + /^\s*#?WEBI_ARCH=.*/m, + "WEBI_ARCH='" + (arch || '') + "'" + ) + .replace(/^\s*#?WEBI_TAG=.*/m, "WEBI_TAG='" + tag + "'") + .replace( + /^\s*#?WEBI_RELEASES=.*/m, "WEBI_RELEASES='" + baseurl + '/api/releases/' + @@ -71,7 +77,7 @@ Releases.renderBash = function ( "'" ) .replace( - /^#?WEBI_CSV=.*/m, + /^\s*#?WEBI_CSV=.*/m, "WEBI_CSV='" + [ rel.version, @@ -91,43 +97,43 @@ Releases.renderBash = function ( "'" ) .replace( - /^#?WEBI_VERSION=.*/m, + /^\s*#?WEBI_VERSION=.*/m, 'WEBI_VERSION=' + JSON.stringify(rel.version) ) - .replace(/^#?WEBI_MAJOR=.*/m, 'WEBI_MAJOR=' + v.major) - .replace(/^#?WEBI_MINOR=.*/m, 'WEBI_MINOR=' + v.minor) - .replace(/^#?WEBI_PATCH=.*/m, 'WEBI_PATCH=' + v.patch) - .replace(/^#?WEBI_BUILD=.*/m, 'WEBI_BUILD=' + v.build) - .replace(/^#?WEBI_LTS=.*/m, 'WEBI_LTS=' + rel.lts) - .replace(/^#?WEBI_CHANNEL=.*/m, 'WEBI_CHANNEL=' + rel.channel) + .replace(/^\s*#?WEBI_MAJOR=.*/m, 'WEBI_MAJOR=' + v.major) + .replace(/^\s*#?WEBI_MINOR=.*/m, 'WEBI_MINOR=' + v.minor) + .replace(/^\s*#?WEBI_PATCH=.*/m, 'WEBI_PATCH=' + v.patch) + .replace(/^\s*#?WEBI_BUILD=.*/m, 'WEBI_BUILD=' + v.build) + .replace(/^\s*#?WEBI_LTS=.*/m, 'WEBI_LTS=' + rel.lts) + .replace(/^\s*#?WEBI_CHANNEL=.*/m, 'WEBI_CHANNEL=' + rel.channel) .replace( - /^#?WEBI_EXT=.*/m, + /^\s*#?WEBI_EXT=.*/m, 'WEBI_EXT=' + rel.ext.replace(/tar.*/, 'tar') ) .replace( - /^#?WEBI_FORMATS=.*/m, + /^\s*#?WEBI_FORMATS=.*/m, "WEBI_FORMATS='" + formats.join(',') + "'" ) .replace( - /^#?WEBI_PKG_URL=.*/m, + /^\s*#?WEBI_PKG_URL=.*/m, "WEBI_PKG_URL='" + rel.download + "'" ) .replace( - /^#?WEBI_PKG_FILE=.*/m, + /^\s*#?WEBI_PKG_FILE=.*/m, "WEBI_PKG_FILE='" + pkgFile + "'" ) // PKG details - .replace(/^#?PKG_NAME=.*/m, "PKG_NAME='" + pkg + "'") + .replace(/^\s*#?PKG_NAME=.*/m, "PKG_NAME='" + pkg + "'") .replace( - /^#?PKG_OSES=.*/m, + /^\s*#?PKG_OSES=.*/m, "PKG_OSES='" + ((rel && rel.oses) || []).join(',') + "'" ) .replace( - /^#?PKG_ARCHES=.*/m, + /^\s*#?PKG_ARCHES=.*/m, "PKG_ARCHES='" + ((rel && rel.arches) || []).join(',') + "'" ) .replace( - /^#?PKG_FORMATS=.*/m, + /^\s*#?PKG_FORMATS=.*/m, "PKG_FORMATS='" + ((rel && rel.formats) || []).join(',') + "'" ) .replace(/{{ installer }}/, installTxt)