Skip to content

Commit 1f08a3c

Browse files
feat: Import-TypeView .sql file support ( Fixes #240 )
1 parent 29b4863 commit 1f08a3c

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

Commands/Types.PS1XML/Import-TypeView.ps1

+15-2
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,15 @@
8383

8484

8585
$membersByType = @{}
86+
$CommonParentPath = $null
8687
foreach ($fp in $FilePath) {
8788
$filePathRoot = Get-Item -Path $fp
89+
if (-not $filePathRoot) { continue}
90+
if (-not $CommonParentPath) {
91+
$CommonParentPath = $filePathRoot.Parent.FullName
92+
} elseif ($CommonParentPath) {
93+
$CommonParentPath | Split-Path -CommonPrefix $filePathRoot
94+
}
8895
$filesBeneathRoot = Get-ChildItem -Recurse -Path $fp -Force
8996

9097
:nextFile foreach ($fileBeneathRoot in $filesBeneathRoot) {
@@ -211,7 +218,7 @@
211218
}
212219

213220
# Do not Skip format/view/control files (this allows them to be in the same directory as types, if that is preferred)
214-
$isFormatFile = $item.Name -match '\.(?>format|view|control)\.ps1$'
221+
$isFormatFile = $item.Name -match '\.(?>format|view|control)\.ps1$'
215222

216223
$itemName =
217224
$item.Name.Substring(0, $item.Name.Length - $item.Extension.Length)
@@ -352,6 +359,12 @@
352359
}
353360
}
354361

362+
.sql {
363+
if (-not $noteProperty.Contains($itemName)) # SQL files become note properties.
364+
{
365+
$noteProperty[$itemName] = $fileText
366+
}
367+
}
355368

356369
#endregion .txt Files
357370
#region .psd1 Files
@@ -406,7 +419,7 @@ return `$convertedFromJson
406419
"@)
407420
}
408421
}
409-
#endregion JSON files
422+
#endregion JSON files
410423
#region CliXML files
411424
# Clixml files are embedded into a ScriptProperty and Deserialized.
412425
.clixml {

0 commit comments

Comments
 (0)