1
+ # This file is part of the Zephir Parser.
2
+ #
3
+ # (c) Zephir Team <[email protected] >
4
+ #
5
+ # For the full copyright and license information, please view the LICENSE
6
+ # file that was distributed with this source code.
7
+
1
8
Function EnsureRequiredDirectoriesPresent {
2
9
If (-not (Test-Path ' C:\Downloads' )) {
3
10
New-Item - ItemType Directory - Force - Path ' C:\Downloads' | Out-Null
@@ -13,7 +20,7 @@ Function Ensure7ZipIsInstalled {
13
20
$7zipInstallationDirectory = " ${Env: ProgramFiles} \7-Zip"
14
21
15
22
If (-not (Test-Path " $7zipInstallationDirectory " )) {
16
- throw " The 7-zip file archiver is needed to use this module"
23
+ Throw " The 7-zip file archiver is needed to use this module"
17
24
}
18
25
19
26
$Env: Path += " ;$7zipInstallationDirectory "
@@ -25,7 +32,7 @@ Function EnsureChocolateyIsInstalled {
25
32
$ChocolateyInstallationDirectory = " ${Env: ProgramData} \chocolatey\bin"
26
33
27
34
If (-not (Test-Path " $ChocolateyInstallationDirectory " )) {
28
- throw " The choco is needed to use this module"
35
+ Throw " The choco is needed to use this module"
29
36
}
30
37
31
38
$Env: Path += " ;$ChocolateyInstallationDirectory "
@@ -37,7 +44,7 @@ Function EnsurePandocIsInstalled {
37
44
$PandocInstallationDirectory = " ${Env: ProgramData} \chocolatey\bin"
38
45
39
46
If (-not (Test-Path " $PandocInstallationDirectory " )) {
40
- throw " The pandoc is needed to use this module"
47
+ Throw " The pandoc is needed to use this module"
41
48
}
42
49
43
50
$Env: Path += " ;$PandocInstallationDirectory "
@@ -124,20 +131,20 @@ Function InitializeBuildVars {
124
131
switch ($Env: VC_VERSION ) {
125
132
' 14' {
126
133
If (-not (Test-Path $Env: VS120COMNTOOLS )) {
127
- throw ' The VS120COMNTOOLS environment variable is not set. Check your MS VS installation'
134
+ Throw ' The VS120COMNTOOLS environment variable is not set. Check your MS VS installation'
128
135
}
129
136
$Env: VSCOMNTOOLS = $Env: VS120COMNTOOLS
130
137
break
131
138
}
132
139
' 15' {
133
140
If (-not (Test-Path $Env: VS140COMNTOOLS )) {
134
- throw ' The VS140COMNTOOLS environment variable is not set. Check your MS VS installation'
141
+ Throw ' The VS140COMNTOOLS environment variable is not set. Check your MS VS installation'
135
142
}
136
143
$Env: VSCOMNTOOLS = $Env: VS140COMNTOOLS
137
144
break
138
145
}
139
146
default {
140
- throw ' This script is designed to run with MS VS 14/15. Check your MS VS installation'
147
+ Throw ' This script is designed to run with MS VS 14/15. Check your MS VS installation'
141
148
break
142
149
}
143
150
}
@@ -205,7 +212,7 @@ Function PrepareReleasePackage {
205
212
$7zipExitCode = $LASTEXITCODE
206
213
If ($7zipExitCode -ne 0 ) {
207
214
Set-Location " ${CurrentPath} "
208
- throw " An error occurred while creating release zippbal to [${Env: RELEASE_ZIPBALL} .zip]. 7Zip Exit Code was [${7zipExitCode} ]"
215
+ Throw " An error occurred while creating release zippbal to [${Env: RELEASE_ZIPBALL} .zip]. 7Zip Exit Code was [${7zipExitCode} ]"
209
216
}
210
217
211
218
Move-Item " ${Env: RELEASE_ZIPBALL} .zip" - Destination " ${Env: APPVEYOR_BUILD_FOLDER} "
@@ -234,13 +241,19 @@ Function SetupPhpVersionString {
234
241
$DestinationPath = " ${Env: Temp} \php-sha1sum.txt"
235
242
236
243
If (-not [System.IO.File ]::Exists($DestinationPath )) {
237
- Write-Host " Downloading PHP SHA Sums: $RemoteUrl ..."
244
+ Write-Host " Downloading PHP SHA Sums: ${ RemoteUrl} ..."
238
245
DownloadFile $RemoteUrl $DestinationPath
239
246
}
240
247
241
- $versions = Get-Content $DestinationPath | Where-Object { $_ -match " php-($Env: PHP_MINOR \.\d+)-src" } | ForEach-Object { $matches [1 ] }
248
+ $VersionString = Get-Content $DestinationPath | Where-Object {
249
+ $_ -match " php-($Env: PHP_MINOR \.\d+)-src"
250
+ } | ForEach-Object { $matches [1 ] }
251
+
252
+ If ($VersionString -NotMatch ' \d+\.\d+\.\d+' ) {
253
+ Throw " Unable to obtain PHP version string using pattern 'php-($Env: PHP_MINOR \.\d+)-src'"
254
+ }
242
255
243
- $Env: PHP_VERSION = $versions .Split (' ' )[-1 ]
256
+ $Env: PHP_VERSION = $VersionString .Split (' ' )[-1 ]
244
257
}
245
258
246
259
Function TuneUpPhp {
@@ -250,7 +263,7 @@ Function TuneUpPhp {
250
263
Write-Host " Tune up PHP: $IniFile " - foregroundcolor Cyan
251
264
252
265
If (-not [System.IO.File ]::Exists($IniFile )) {
253
- throw " Unable to locate $IniFile file"
266
+ Throw " Unable to locate $IniFile file"
254
267
}
255
268
256
269
Write-Output " " | Out-File - Encoding " ASCII" - Append $IniFile
@@ -272,11 +285,11 @@ Function EnableExtension {
272
285
$PhpExe = " ${Env: PHP_PATH} \php.exe"
273
286
274
287
If (-not [System.IO.File ]::Exists($IniFile )) {
275
- throw " Unable to locate ${IniFile} "
288
+ Throw " Unable to locate ${IniFile} "
276
289
}
277
290
278
291
If (-not (Test-Path " ${ExtPath} " )) {
279
- throw " Unable to locate extension path: ${ExtPath} "
292
+ Throw " Unable to locate extension path: ${ExtPath} "
280
293
}
281
294
282
295
Write-Output " [${Env: EXTENSION_NAME} ]" | Out-File - Encoding " ASCII" - Append $IniFile
@@ -288,7 +301,7 @@ Function EnableExtension {
288
301
$PhpExitCode = $LASTEXITCODE
289
302
If ($PhpExitCode -ne 0 ) {
290
303
PrintPhpInfo
291
- throw " An error occurred while enabling [${Env: EXTENSION_NAME} ] in [$IniFile ]. PHP Exit Code was [$PhpExitCode ]."
304
+ Throw " An error occurred while enabling [${Env: EXTENSION_NAME} ] in [$IniFile ]. PHP Exit Code was [$PhpExitCode ]."
292
305
}
293
306
}
294
307
}
@@ -347,7 +360,7 @@ Function Expand-Item7zip {
347
360
)
348
361
349
362
If (-not (Test-Path - Path $Archive - PathType Leaf)) {
350
- throw " Specified archive File is invalid: [$Archive ]"
363
+ Throw " Specified archive File is invalid: [$Archive ]"
351
364
}
352
365
353
366
If (-not (Test-Path - Path $Destination - PathType Container)) {
@@ -358,7 +371,7 @@ Function Expand-Item7zip {
358
371
359
372
$7zipExitCode = $LASTEXITCODE
360
373
If ($7zipExitCode -ne 0 ) {
361
- throw " An error occurred while unzipping [$Archive ] to [$Destination ]. 7Zip Exit Code was [$7zipExitCode ]"
374
+ Throw " An error occurred while unzipping [$Archive ] to [$Destination ]. 7Zip Exit Code was [$7zipExitCode ]"
362
375
}
363
376
}
364
377
@@ -374,7 +387,8 @@ Function DownloadFile {
374
387
$RetryCount = 0
375
388
$Completed = $false
376
389
377
- $WebClient = new-object System.Net.WebClient
390
+ $WebClient = New-Object System.Net.WebClient
391
+ $WebClient.Headers.Add (' User-Agent' , ' AppVeyor PowerShell Script' )
378
392
379
393
While (-not $Completed ) {
380
394
Try {
0 commit comments