Skip to content

Commit

Permalink
Merge pull request #1735 from ElijahReva/windows-choco-fixes
Browse files Browse the repository at this point in the history
Add Force parameter to Choco Push
  • Loading branch information
matthid committed Jan 27, 2018
2 parents a1e8a36 + bb60fb3 commit 8e68acc
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/app/Fake.Windows.Chocolatey/Chocolatey.fs
Expand Up @@ -218,6 +218,11 @@ module Fake.Windows.Choco
/// Do not prompt for user input or confirmations. Default `true`.
/// Equivalent to the `-y` option.
NonInteractive: bool
/// Force - force the behavior. Do not use force during normal operation -
/// it subverts some of the smart behavior for commands. Maybe used for pushing
/// packages ot insecure private feeds. Default `false`.
/// Equivalent to the `--force` option.
Force: bool
}

type private NuspecData = {
Expand Down Expand Up @@ -319,6 +324,7 @@ module Fake.Windows.Choco
ApiKey = null
ToolPath = null
AdditionalArgs = null
Force = false
}

let private getPaths =
Expand Down Expand Up @@ -822,7 +828,31 @@ module Fake.Windows.Choco
|> appendWithoutQuotesIfNotNull parameters.Source "--source "
|> appendWithoutQuotesIfNotNull parameters.ApiKey "--apikey "
|> appendIfTrueWithoutQuotes parameters.NonInteractive "-y"
|> appendWithoutQuotesIfNotNull parameters.AdditionalArgs parameters.AdditionalArgs
|> appendIfTrueWithoutQuotes parameters.Force "--force"
|> appendIfTrueWithoutQuotes (parameters.AdditionalArgs |> String.isNotNullOrEmpty) parameters.AdditionalArgs
|> toText

callChoco parameters.ToolPath args parameters.Timeout

/// Call custom choco command
/// ## Parameters
/// - `args` - string that will be appendedn to choco.exe call
/// - `timeout` - parrent process maximum completion time
/// ## Sample usage
///
/// Target "ChocoPush" (fun _ ->
///
/// let newSpecFile = ...
/// let args =
/// new StringBuilder()
/// |> append "pack"
/// |> append newSpecFile
/// |> append "-y"
/// |> toText
///
/// args |> Choco.CallChoco TimeSpan.FromMinutes 1.
/// )
let CallChoco args timeout =
if args |> isNullOrEmpty then failwith "'args' must not be empty."

callChoco null args timeout

0 comments on commit 8e68acc

Please sign in to comment.