Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function remove-folder($path) {
- remove-item $path -Recurse -Force -ErrorAction SilentlyContinue | out-null
- }
- function generate-from-template($templatePath, $destinationPath, $templateSubstitutions) {
- foreach($templateSubstitution in $templateSubstitutions.GetEnumerator()) {
- Set-Variable -Name ($templateSubstitution.Name) -Value ($templateSubstitution.Value)
- }
- [System.IO.File]::WriteAllText(
- $destinationPath,
- $ExecutionContext.InvokeCommand.ExpandString([IO.File]::ReadAllText($templatePath)),
- [System.Text.Encoding]::UTF8)
- }
- function argrest($arguments, $index) {
- if ($index -ge $arguments.Length) {
- return "";
- }
- return $arguments[$index..($arguments.Length-1)] -join " "
- }
- function info($text) {
- Write-Host
- Write-Host $text -fore CYAN
- Write-Host
- }
- function error($text) {
- Write-Host
- Write-Host $text -fore RED
- Write-Host
- }
- function exec($command, $path) {
- if ($null -eq $path) {
- $global:lastexitcode = 0
- & $command
- } else {
- Push-Location $path
- $global:lastexitcode = 0
- & $command
- Pop-Location
- }
- if ($lastexitcode -ne 0) {
- throw "Error executing command: $command"
- }
- }
- function run-self-async {
- [string[]] $arguments = @("-File", ".\go.ps1") + ($args | % {'"' + $_ + '"'})
- Start-Process powershell -ArgumentList $arguments
- }
- function main($mainBlock) {
- try {
- &$mainBlock
- exit 0
- } catch [Exception] {
- write-host
- write-host $_.Exception.Message -fore DARKRED
- exit 1
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement