@@ -22,9 +22,16 @@ function Get-FileEncoding
22
22
$Path
23
23
)
24
24
25
- [byte []]$byte = get-content - Encoding byte - ReadCount 4 - TotalCount 4 - Path $Path
25
+ if ($PSVersionTable.PSVersion.Major -lt 6 )
26
+ {
27
+ [byte []]$byte = get-content - Encoding byte - ReadCount 4 - TotalCount 4 - Path $Path
28
+ }
29
+ else
30
+ {
31
+ [byte []]$byte = Get-Content - AsByteStream - ReadCount 4 - TotalCount 4 - Path $Path
32
+ }
26
33
27
- if ($byte [0 ] -eq 0xef -and $byte [1 ] -eq 0xbb -and $byte [2 ] -eq 0xbf ) { ' UTF8' }
34
+ if ($byte [0 ] -eq 0xef -and $byte [1 ] -eq 0xbb -and $byte [2 ] -eq 0xbf ) { ' UTF8 BOM ' }
28
35
elseif ($byte [0 ] -eq 0xfe -and $byte [1 ] -eq 0xff ) { ' Unicode' }
29
36
elseif ($byte [0 ] -eq 0 -and $byte [1 ] -eq 0 -and $byte [2 ] -eq 0xfe -and $byte [3 ] -eq 0xff ) { ' UTF32' }
30
37
elseif ($byte [0 ] -eq 0x2b -and $byte [1 ] -eq 0x2f -and $byte [2 ] -eq 0x76 ) { ' UTF7' }
@@ -39,8 +46,8 @@ Describe "Verifying integrity of module files" {
39
46
{
40
47
$name = $file.FullName.Replace (" $moduleRoot \" , ' ' )
41
48
42
- It " [$name ] Should have UTF8 encoding" {
43
- Get-FileEncoding - Path $file.FullName | Should - Be ' UTF8'
49
+ It " [$name ] Should have UTF8 encoding with Byte Order Mark " {
50
+ Get-FileEncoding - Path $file.FullName | Should - Be ' UTF8 BOM '
44
51
}
45
52
46
53
It " [$name ] Should have no trailing space" {
@@ -64,10 +71,6 @@ Describe "Verifying integrity of module files" {
64
71
}
65
72
}
66
73
}
67
-
68
- It " [$name ] Should not contain aliases" {
69
- $tokens | Where-Object TokenFlags -eq CommandName | Where-Object { Test-Path " alias:\$ ( $_.Text ) " } | Measure-Object | Select-Object - ExpandProperty Count | Should - Be 0
70
- }
71
74
}
72
75
}
73
76
@@ -79,7 +82,7 @@ Describe "Verifying integrity of module files" {
79
82
$name = $file.FullName.Replace (" $moduleRoot \" , ' ' )
80
83
81
84
It " [$name ] Should have UTF8 encoding" {
82
- Get-FileEncoding - Path $file.FullName | Should - Be ' UTF8'
85
+ Get-FileEncoding - Path $file.FullName | Should - Be ' UTF8 BOM '
83
86
}
84
87
85
88
It " [$name ] Should have no trailing space" {
0 commit comments