Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Force parameter to Choco Push #1735

Merged
merged 2 commits into from
Jan 27, 2018
Merged
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
32 changes: 31 additions & 1 deletion src/app/Fake.Windows.Chocolatey/Chocolatey.fs
Original file line number Diff line number Diff line change
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 =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe "Exec" so that it reads Choco.Exec in the code? (currently it will read Choco.CallChoco)

if args |> isNullOrEmpty then failwith "'args' must not be empty."

callChoco null args timeout