-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathinstall.ps1
39 lines (35 loc) · 1.85 KB
/
install.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
$OS = $([System.Environment]::OSVersion).VersionString
$ARCH = $env:PROCESSOR_ARCHITECTURE.ToLower()
Write-Host "Current system: " -NoNewline
Write-Host $OS -ForegroundColor Green -NoNewline
Write-Host " (architecture: " -NoNewline
Write-Host $ARCH -ForegroundColor Green -NoNewline
Write-Host ")"
$dstPath = "$env:LOCALAPPDATA\lazyjournal"
if (!(Test-Path $dstPath)) {
New-Item -Path $dstPath -ItemType Directory | Out-Null
Write-Host "Directory created: " -NoNewline
Write-Host $dstPath -ForegroundColor Blue
}
$beforeEnvPath = [Environment]::GetEnvironmentVariable("Path", "User")
if (!($($beforeEnvPath).Split(";") -contains $dstPath)) {
$afterEnvPath = $beforeEnvPath + ";$dstPath"
[Environment]::SetEnvironmentVariable("Path", $afterEnvPath, "User")
Write-Host "The path has been added to the Path environment variable for the current user."
}
$GITHUB_LATEST_VERSION = (Invoke-RestMethod "https://api.github.com/repos/Lifailon/lazyjournal/releases/latest").tag_name
if ($null -ne $GITHUB_LATEST_VERSION) {
$urlDownload = "https://github.com/Lifailon/lazyjournal/releases/download/$GITHUB_LATEST_VERSION/lazyjournal-$GITHUB_LATEST_VERSION-windows-$ARCH.exe"
Invoke-RestMethod -Uri $urlDownload -OutFile "$dstPath\lazyjournal.exe"
Write-Host "✔ Installation completed " -NoNewline
Write-Host "successfully" -ForegroundColor Green -NoNewline
Write-Host " in " -NoNewline
Write-Host "$dstPath\lazyjournal.exe" -ForegroundColor Blue -NoNewline
Write-Host " (version: $GITHUB_LATEST_VERSION)"
Write-Host "To launch the interface from anywhere" -NoNewline
Write-Host " re-login " -ForegroundColor Green -NoNewline
Write-Host "to the current session"
} else {
Write-Host "Error. " -ForegroundColor Red -NoNewline
Write-Host "Unable to get the latest version from GitHub repository, check your internet connection."
}