mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Encoding for New-ModuleManifest on all platforms should be UTF-8 NoBOM (#5923)
* encoding for new-modulemanifest on all platforms should be utf8nobom * fix test
This commit is contained in:
committed by
Aditya Patwardhan
parent
d3a775da9a
commit
7437f3dd3a
@@ -939,21 +939,17 @@ namespace Microsoft.PowerShell.Commands
|
||||
|
||||
// Now open the output file...
|
||||
PathUtils.MasterStreamOpen(
|
||||
this,
|
||||
filePath,
|
||||
#if UNIX
|
||||
new UTF8Encoding(false), // UTF-8, no BOM
|
||||
#else
|
||||
EncodingConversion.Unicode, // UTF-16 with BOM
|
||||
#endif
|
||||
/* defaultEncoding */ false,
|
||||
/* Append */ false,
|
||||
/* Force */ false,
|
||||
/* NoClobber */ false,
|
||||
out fileStream,
|
||||
out streamWriter,
|
||||
out readOnlyFileInfo,
|
||||
false
|
||||
cmdlet : this,
|
||||
filePath : filePath,
|
||||
resolvedEncoding : new UTF8Encoding(encoderShouldEmitUTF8Identifier : false),
|
||||
defaultEncoding : false,
|
||||
Append : false,
|
||||
Force : false,
|
||||
NoClobber : false,
|
||||
fileStream : out fileStream,
|
||||
streamWriter : out streamWriter,
|
||||
readOnlyFileInfo : out readOnlyFileInfo,
|
||||
isLiteralPath : false
|
||||
);
|
||||
|
||||
try
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Describe "New-ModuleManifest tests" -tags "CI" {
|
||||
BeforeEach {
|
||||
New-Item -ItemType Directory -Path testdrive:/module
|
||||
$null = New-Item -ItemType Directory -Path testdrive:/module
|
||||
$testModulePath = "testdrive:/module/test.psd1"
|
||||
}
|
||||
|
||||
@@ -9,13 +9,10 @@ Describe "New-ModuleManifest tests" -tags "CI" {
|
||||
}
|
||||
|
||||
BeforeAll {
|
||||
if ($IsWindows)
|
||||
{
|
||||
$ExpectedManifestBytes = @(255,254,35,0,13,0,10,0)
|
||||
}
|
||||
else
|
||||
{
|
||||
$ExpectedManifestBytes = @(35,10)
|
||||
if ($IsWindows) {
|
||||
$ExpectedManifestBytes = @(35,13) # CR
|
||||
} else {
|
||||
$ExpectedManifestBytes = @(35,10) # LF
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,10 +35,9 @@ Describe "New-ModuleManifest tests" -tags "CI" {
|
||||
}
|
||||
|
||||
It "Verify module manifest encoding" {
|
||||
|
||||
|
||||
# verify first line of the manifest:
|
||||
# on Windows platforms - 3 characters - '#' '\r' '\n' - in UTF-16 with BOM - this should be @(255,254,35,0,13,0,10,0)
|
||||
# on non-Windows platforms - 2 characters - '#' '\n' - in UTF-8 no BOM - this should be @(35,10)
|
||||
# 2 characters - '#' '\n' - in UTF-8 no BOM - this should be @(35,10)
|
||||
TestNewModuleManifestEncoding -expected $ExpectedManifestBytes
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user