This repository was archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 79
/
Copy pathappveyor.ps1
82 lines (71 loc) · 2.59 KB
/
appveyor.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
Set-StrictMode -Version Latest
$script:PACKAGE_FOLDER = "$env:APPVEYOR_BUILD_FOLDER"
Set-Location $script:PACKAGE_FOLDER
$script:ATOM_CHANNEL = "stable"
$script:ATOM_DIRECTORY_NAME = "Atom"
if ($env:ATOM_CHANNEL -and ($env:ATOM_CHANNEL.tolower() -ne "stable")) {
$script:ATOM_CHANNEL = "$env:ATOM_CHANNEL"
$script:ATOM_DIRECTORY_NAME = "$script:ATOM_DIRECTORY_NAME "
$script:ATOM_DIRECTORY_NAME += $script:ATOM_CHANNEL.substring(0,1).toupper()
$script:ATOM_DIRECTORY_NAME += $script:ATOM_CHANNEL.substring(1).tolower()
}
$script:ATOM_EXE_PATH = "$script:PACKAGE_FOLDER\$script:ATOM_DIRECTORY_NAME\atom.exe"
$script:ATOM_SCRIPT_PATH = "$script:PACKAGE_FOLDER\$script:ATOM_DIRECTORY_NAME\resources\cli\atom.cmd"
$script:APM_SCRIPT_PATH = "$script:PACKAGE_FOLDER\$script:ATOM_DIRECTORY_NAME\resources\app\apm\bin\apm.cmd"
$script:NPM_SCRIPT_PATH = "$script:PACKAGE_FOLDER\$script:ATOM_DIRECTORY_NAME\resources\app\apm\node_modules\.bin\npm.cmd"
function DownloadAtom() {
Write-Host "Downloading latest Atom release..."
$source = "https://atom.io/download/windows_zip?channel=$script:ATOM_CHANNEL"
$destination = "$script:PACKAGE_FOLDER\atom.zip"
appveyor DownloadFile $source -FileName $destination
if ($LASTEXITCODE -ne 0) {
ExitWithCode -exitcode $LASTEXITCODE
}
}
function ExtractAtom() {
Remove-Item "$script:PACKAGE_FOLDER\$script:ATOM_DIRECTORY_NAME" -Recurse -ErrorAction Ignore
Unzip "$script:PACKAGE_FOLDER\atom.zip" "$script:PACKAGE_FOLDER"
}
Add-Type -AssemblyName System.IO.Compression.FileSystem
function Unzip
{
param([string]$zipfile, [string]$outpath)
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath)
}
function PrintVersions() {
Write-Host -NoNewLine "Using Atom version: "
& "$script:ATOM_EXE_PATH" --version
if ($LASTEXITCODE -ne 0) {
ExitWithCode -exitcode $LASTEXITCODE
}
Write-Host "Using APM version: "
& "$script:APM_SCRIPT_PATH" -v
if ($LASTEXITCODE -ne 0) {
ExitWithCode -exitcode $LASTEXITCODE
}
}
function ExitWithCode
{
param
(
$exitcode
)
$host.SetShouldExit($exitcode)
exit
}
function SetElectronEnvironmentVariables
{
$env:ELECTRON_NO_ATTACH_CONSOLE = "true"
[Environment]::SetEnvironmentVariable("ELECTRON_NO_ATTACH_CONSOLE", "true", "User")
$env:ELECTRON_ENABLE_LOGGING = "YES"
[Environment]::SetEnvironmentVariable("ELECTRON_ENABLE_LOGGING", "YES", "User")
}
function AddAtomToPath
{
$env:PATH += ";$script:PACKAGE_FOLDER\$script:ATOM_DIRECTORY_NAME\"
}
DownloadAtom
ExtractAtom
SetElectronEnvironmentVariables
PrintVersions
AddAtomToPath