bugfix: allow whitespace before template vars
authorAJ ONeal <aj@therootcompany.com>
Mon, 26 Apr 2021 07:20:10 +0000 (07:20 +0000)
committerAJ ONeal <aj@therootcompany.com>
Mon, 26 Apr 2021 07:20:10 +0000 (07:20 +0000)
_webi/releases.js

index c7b0b519a9008f4060ab0eb36097229460a5d6a2..31f3b59576dd59031ddeff658157ae91669dcebc 100644 (file)
@@ -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)