Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -939,21 +939,17 @@ protected override void EndProcessing()

// 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
Expand Down
18 changes: 7 additions & 11 deletions test/powershell/engine/Module/NewModuleManifest.Tests.ps1
Original file line number Diff line number Diff line change
@@ -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"
}

Expand All @@ -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
}
}

Expand All @@ -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
}

Expand Down