Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed yaml variable in script defaults #209

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading