From 96b9ebe8acf9c123aa0c94ce8377d55adbee4dfa Mon Sep 17 00:00:00 2001 From: AdmiringWorm Date: Fri, 23 Sep 2022 12:53:23 +0200 Subject: [PATCH] (maint) Whitespace + formatting fix --- .../services/IPowershellService.cs | 2 +- .../services/PowershellService.cs | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/chocolatey/infrastructure.app/services/IPowershellService.cs b/src/chocolatey/infrastructure.app/services/IPowershellService.cs index 5e19da6c2d..097cb278e0 100644 --- a/src/chocolatey/infrastructure.app/services/IPowershellService.cs +++ b/src/chocolatey/infrastructure.app/services/IPowershellService.cs @@ -1,4 +1,4 @@ -// Copyright © 2017 - 2021 Chocolatey Software, Inc +// Copyright © 2017 - 2022 Chocolatey Software, Inc // Copyright © 2011 - 2017 RealDimensions Software, LLC // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/chocolatey/infrastructure.app/services/PowershellService.cs b/src/chocolatey/infrastructure.app/services/PowershellService.cs index dba64d54fc..e57e66b98e 100644 --- a/src/chocolatey/infrastructure.app/services/PowershellService.cs +++ b/src/chocolatey/infrastructure.app/services/PowershellService.cs @@ -1,4 +1,4 @@ -// Copyright © 2017 - 2021 Chocolatey Software, Inc +// Copyright © 2017 - 2022 Chocolatey Software, Inc // Copyright © 2011 - 2017 RealDimensions Software, LLC // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,10 +23,7 @@ namespace chocolatey.infrastructure.app.services using System.Management.Automation; using System.Management.Automation.Runspaces; using System.Reflection; - using System.Security.Cryptography; - using System.Text; using adapters; - using builders; using commandline; using configuration; using cryptography; @@ -38,8 +35,6 @@ namespace chocolatey.infrastructure.app.services using powershell; using results; using utility; - using Assembly = adapters.Assembly; - using Console = System.Console; using CryptoHashProvider = cryptography.CryptoHashProvider; using Environment = System.Environment; using IFileSystem = filesystem.IFileSystem; @@ -112,12 +107,15 @@ private IEnumerable get_hook_scripts(ChocolateyConfiguration configurati case CommandNameType.install: filenameBase += "install-"; break; + case CommandNameType.uninstall: filenameBase += "uninstall-"; break; + case CommandNameType.upgrade: filenameBase += "beforemodify-"; break; + default: throw new ApplicationException("Could not find CommandNameType '{0}' to get hook scripts".format_with(command)); } @@ -353,7 +351,6 @@ public bool run_action(ChocolateyConfiguration configuration, PackageResult pack `choco -h` for details."); } - if (result.ExitCode != 0) { Environment.ExitCode = result.ExitCode; @@ -534,7 +531,7 @@ public void prepare_powershell_environment(IPackage package, ChocolateyConfigura } } - SecurityProtocol.set_protocol(configuration, provideWarning:false); + SecurityProtocol.set_protocol(configuration, provideWarning: false); } private ResolveEventHandler _handler = null; @@ -738,11 +735,11 @@ public PowerShellExecutionResults run_host(ChocolateyConfiguration config, strin if (host.ExitCode == 0) host.SetShouldExit(1); host.HostException = pipeline.PipelineStateInfo.Reason; break; + case PipelineState.Completed: if (host.ExitCode == -1) host.SetShouldExit(0); break; } - } } }