-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
578 additions
and
9 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
[CmdletBinding()] | ||
param( | ||
[Parameter(Mandatory = $true)] | ||
[string]$Source, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[string]$Target) | ||
|
||
# This script translates the output from 7zdec into UTF8. Node has limited | ||
# built-in support for encodings. | ||
# | ||
# 7zdec uses the system default code page. The system default code page varies | ||
# depending on the locale configuration. On an en-US box, the system default code | ||
# page is Windows-1252. | ||
# | ||
# Note, on a typical en-US box, testing with the 'ç' character is a good way to | ||
# determine whether data is passed correctly between processes. This is because | ||
# the 'ç' character has a different code point across each of the common encodings | ||
# on a typical en-US box, i.e. | ||
# 1) the default console-output code page (IBM437) | ||
# 2) the system default code page (i.e. CP_ACP) (Windows-1252) | ||
# 3) UTF8 | ||
|
||
$ErrorActionPreference = 'Stop' | ||
|
||
# Redefine the wrapper over STDOUT to use UTF8. Node expects UTF8 by default. | ||
$stdout = [System.Console]::OpenStandardOutput() | ||
$utf8 = New-Object System.Text.UTF8Encoding($false) # do not emit BOM | ||
$writer = New-Object System.IO.StreamWriter($stdout, $utf8) | ||
[System.Console]::SetOut($writer) | ||
|
||
# All subsequent output must be written using [System.Console]::WriteLine(). In | ||
# PowerShell 4, Write-Host and Out-Default do not consider the updated stream writer. | ||
|
||
Set-Location -LiteralPath $Target | ||
|
||
# Print the ##command. | ||
$_7zdec = Join-Path -Path "$PSScriptRoot" -ChildPath "externals/7zdec.exe" | ||
[System.Console]::WriteLine("##[command]$_7zdec x `"$Source`"") | ||
|
||
# The $OutputEncoding variable instructs PowerShell how to interpret the output | ||
# from the external command. | ||
$OutputEncoding = [System.Text.Encoding]::Default | ||
|
||
# Note, the output from 7zdec.exe needs to be iterated over. Otherwise PowerShell.exe | ||
# will launch the external command in such a way that it inherits the streams. | ||
& $_7zdec x $Source 2>&1 | | ||
ForEach-Object { | ||
if ($_ -is [System.Management.Automation.ErrorRecord]) { | ||
[System.Console]::WriteLine($_.Exception.Message) | ||
} | ||
else { | ||
[System.Console]::WriteLine($_) | ||
} | ||
} | ||
[System.Console]::WriteLine("##[debug]7zdec.exe exit code '$LASTEXITCODE'") | ||
[System.Console]::Out.Flush() | ||
if ($LASTEXITCODE -ne 0) { | ||
exit $LASTEXITCODE | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.