aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2017-02-16 18:48:14 -0800
committerAlexander Karatarakis <alkarata@microsoft.com>2017-02-16 18:48:14 -0800
commit7b4cae57be4e42113b70fd755988623236a95bd7 (patch)
tree8ad6bd252df559408c535e69549c63a8618ab8be /scripts
parent82585b25abbad56b53c691dadf04b4cc9677dfd4 (diff)
downloadvcpkg-7b4cae57be4e42113b70fd755988623236a95bd7.tar.gz
vcpkg-7b4cae57be4e42113b70fd755988623236a95bd7.zip
fetchDependency.ps1: add option to override prompting for download
Diffstat (limited to 'scripts')
-rw-r--r--scripts/fetchDependency.ps118
1 files changed, 14 insertions, 4 deletions
diff --git a/scripts/fetchDependency.ps1 b/scripts/fetchDependency.ps1
index 71f9e1089..6a40c9758 100644
--- a/scripts/fetchDependency.ps1
+++ b/scripts/fetchDependency.ps1
@@ -1,8 +1,14 @@
[CmdletBinding()]
param(
- [string]$Dependency
+ [string]$Dependency,
+ [ValidateNotNullOrEmpty()]
+ [string]$downloadPromptOverride = "0"
)
+$downloadPromptOverride_NO_OVERRIDE= 0
+$downloadPromptOverride_DO_NOT_PROMPT = 1
+$downloadPromptOverride_ALWAYS_PROMPT = 2
+
Import-Module BitsTransfer
$scriptsDir = split-path -parent $MyInvocation.MyCommand.Definition
@@ -12,9 +18,13 @@ $downloadsDir = "$vcpkgRootDir\downloads"
function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency)
{
- function promptForDownload([string]$title, [string]$message, [string]$yesDescription, [string]$noDescription)
+ function promptForDownload([string]$title, [string]$message, [string]$yesDescription, [string]$noDescription, [string]$downloadPromptOverride)
{
- if ((Test-Path "$downloadsDir\AlwaysAllowEverything") -Or (Test-Path "$downloadsDir\AlwaysAllowDownloads"))
+ $do_not_prompt = ($downloadPromptOverride -eq $downloadPromptOverride_DO_NOT_PROMPT) -Or
+ (Test-Path "$downloadsDir\AlwaysAllowEverything") -Or
+ (Test-Path "$downloadsDir\AlwaysAllowDownloads")
+
+ if (($downloadPromptOverride -ne $downloadPromptOverride_ALWAYS_PROMPT) -And $do_not_prompt)
{
return $true
}
@@ -57,7 +67,7 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency)
$yesDescription = "Downloads " + $Dependency + " v" + $downloadVersion +" app-locally."
$noDescription = "Does not download " + $Dependency + "."
- $userAllowedDownload = promptForDownload $title $message $yesDescription $noDescription
+ $userAllowedDownload = promptForDownload $title $message $yesDescription $noDescription $downloadPromptOverride
if (!$userAllowedDownload)
{
throw [System.IO.FileNotFoundException] ("Could not detect suitable version of " + $Dependency + " and download not allowed")