Skip to content

Commit 6c891b6

Browse files
committed
UseCorrectCasing: Preserve script paths
1 parent c23bf1c commit 6c891b6

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Rules/UseCorrectCasing.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public override IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string file
5151
}
5252

5353
var commandInfo = Helper.Instance.GetCommandInfo(commandName);
54-
if (commandInfo == null)
54+
if (commandInfo == null || commandInfo.CommandType == CommandTypes.ExternalScript)
5555
{
5656
continue;
5757
}

Tests/Rules/UseCorrectCasing.tests.ps1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,11 @@ Describe "UseCorrectCasing" {
3838
}
3939
Invoke-Formatter 'invoke-dummyFunction' | Should -Be 'Invoke-DummyFunction'
4040
}
41+
42+
It "preserves script paths" -Skip:($IsLinux -or $IsMacOS) {
43+
$uncPath = [System.IO.Path]::Combine("\\$(HOSTNAME.EXE)\C$\", $TestDrive, "$(New-Guid).ps1")
44+
New-Item -ItemType File -Path $uncPath
45+
$scriptDefinition = ". $uncPath"
46+
Invoke-Formatter $scriptDefinition | Should -Be $scriptDefinition
47+
}
4148
}

0 commit comments

Comments
 (0)