11function DownloadAtom {
22 Write-Host " Downloading latest Atom release..."
33
4- $Source = " https://atom.io/download/windows_zip?channel=stable"
4+ $Source = " https://atom.io/download/windows_zip?channel=stable"
55 $Destination = Join-Path . ' \atom.zip'
66
77 try {
88 Invoke-WebRequest $Source - OutFile $Destination - ErrorAction Stop
9- } catch {
9+ }
10+ catch {
1011 $PSCmdlet.ThrowTerminatingError ($PSItem )
1112 }
1213
@@ -24,7 +25,8 @@ function ExtractAtom {
2425 try {
2526 Add-Type - AssemblyName System.IO.Compression.FileSystem
2627 [System.IO.Compression.ZipFile ]::ExtractToDirectory($ZipFile , $OutPath )
27- } catch {
28+ }
29+ catch {
2830 $PSCmdlet.ThrowTerminatingError ($PSItem )
2931 }
3032
@@ -35,24 +37,27 @@ function ExtractAtom {
3537 Write-Host " Atom.zip deleted..."
3638}
3739
38- function ParseJasmine ($String ) {
39- if ($String -match " ^\s+at.*$" ) {
40- ' '
41- return
42- }
40+ filter ParseJasmine {
41+ switch - regex ($_ ) {
42+ ^\s+ at {
43+ ' '
44+ break
45+ }
4346
44- if ( $_ -match " ^\s+it.*$ " ) {
45- $_ -replace ' ^(\s+)(it)' , ' $1[-] It'
46- return
47- }
47+ ^\s+ it {
48+ $_ -replace ' ^(\s+)(it)' , ' $1[-] It'
49+ break
50+ }
4851
49- if ($_ -match " ^\s+Expected.*$" ) {
50- $x = $_ -replace ' ^(\s*)(Expected)(.*)\s(to equal .*)' , ' $1$2$3%%$1$4'
51- $x.Replace (' %%' , " `n " )
52- return
53- }
52+ ^\s+ Expected {
53+ $_ -replace ' ^(\s*)(Expected.*?)\s(instead found .*)' , " `$ 1`$ 2`n`$ 1`$ 3"
54+ break
55+ }
5456
55- $_
57+ default {
58+ $_
59+ }
60+ }
5661}
5762
5863function ExitWithCode {
@@ -70,15 +75,17 @@ function RunSpecs {
7075 $specpath = Join-Path . ' \spec'
7176
7277 if (Test-Path $specpath ) {
73- & " $script :ATOM_EXE_PATH " -- test spec * > & 1 | ForEach-Object { ParseJasmine $_ }
74- } else {
78+ & $script :ATOM_EXE_PATH -- test $specpath * > & 1 | ParseJasmine
79+ }
80+ else {
7581 throw ' .\spec\ not found.'
7682 }
7783
7884 if ($LASTEXITCODE -ne 0 ) {
7985 if ($Env: APPVEYOR ) {
8086 ExitWithCode - exitcode $LASTEXITCODE
81- } else {
87+ }
88+ else {
8289 throw " One or more tests failed."
8390 }
8491 }
0 commit comments