Skip to content

Commit 10c60f9

Browse files
Refactor ConvertFrom-Lua to use a hashtable for parameters and improve error message for reserved words in Read-LuaTable
1 parent dca2439 commit 10c60f9

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/functions/private/Read-LuaTable.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@
9191
if ($script:luaSkipValidation) {
9292
Write-Warning "Reserved word '$ident' used as a bare identifier key at position $identStart."
9393
} else {
94-
throw "Reserved word '$ident' cannot be used as a bare identifier key in a Lua table. Use bracket notation: [`"$ident`"] = value."
94+
$msg = "Reserved word '$ident' cannot be used as a bare identifier key" +
95+
" in a Lua table. Use bracket notation: [`"$ident`"] = value."
96+
throw $msg
9597
}
9698
}
9799
# Key = value pair

src/functions/public/Lua/ConvertFrom-Lua.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,13 @@
8787
begin {}
8888

8989
process {
90-
$result = ConvertFrom-LuaTable -InputString $InputObject -AsPSCustomObject:(-not $AsHashtable) -MaxDepth $Depth -SkipValidation:$SkipValidation
90+
$convertParams = @{
91+
InputString = $InputObject
92+
AsPSCustomObject = -not $AsHashtable
93+
MaxDepth = $Depth
94+
SkipValidation = $SkipValidation.IsPresent
95+
}
96+
$result = ConvertFrom-LuaTable @convertParams
9197
if ($NoEnumerate -and $result -is [System.Array]) {
9298
Write-Output -InputObject $result -NoEnumerate
9399
} else {

0 commit comments

Comments
 (0)