Skip to content

Commit

Permalink
Merge pull request #209 from NoxOrg/bugfix/yaml-variables
Browse files Browse the repository at this point in the history
fixed yaml variable in script defaults
  • Loading branch information
jan-schutte authored Apr 2, 2024
2 parents d535b38 + 047f61f commit 4fc99d6
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Nox.Cli.Abstractions;
using Nox.Cli.Abstractions.Exceptions;
using Nox.Cli.Abstractions.Extensions;
using Nox.Cli.Helpers;
using Nox.Cli.Plugin.Console.JsonSchema;
using RestSharp;
using Spectre.Console;
Expand Down Expand Up @@ -550,17 +549,16 @@ private void AppendKey(string yamlSpacing, string key)
{
if (_defaults?.ContainsKey(key) ?? false)
{
var defaultValue = _defaults[key];
var match = _yamlVariableRegex.Match(defaultValue.ToString()!);
if (match.Success)
var defaultValue = _defaults[key].ToString() ?? "";
var match = _yamlVariableRegex.Match(defaultValue);
while (match.Success)
{
var variableValue = _responses[match.Groups["variable"].ToString()].ToString();
return (T)Convert.ChangeType(defaultValue.ToString()!.Replace(match.Groups[0].ToString(), variableValue), typeof(T));
}
else
{
return (T)Convert.ChangeType(defaultValue, typeof(T));
defaultValue = defaultValue.Replace(match.Groups[0].ToString(), variableValue);
match = _yamlVariableRegex.Match(defaultValue);
}
return (T)Convert.ChangeType(defaultValue, typeof(T))!;

}

return default;
Expand Down

0 comments on commit 4fc99d6

Please sign in to comment.