Skip to content

Commit c64888a

Browse files
Update install.ps1
1 parent 43c24d7 commit c64888a

1 file changed

Lines changed: 16 additions & 15 deletions

File tree

docs/install.ps1

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ $EXE_PATH = Join-Path -Path $INSTALL_DIR -ChildPath "$($APP_NAME.CLI).exe"
99

1010
Function Remove-IfNeeded {
1111
if ($args.Count -gt 0 -and ($args[0] -as [int])) {
12+
Write-Output "Updating existing install (PID $args[0])"
1213
Stop-Process -Id $args[0] -Force
1314
Remove-Item $EXE_PATH -Force
1415
}
@@ -17,13 +18,13 @@ Function Remove-IfNeeded {
1718
# get latest release URL
1819
Function Get-LatestReleaseUrl {
1920
try {
20-
Write-Host "Fetching latest release from GitHub..."
21+
Write-Output "Fetching latest release from GitHub..."
2122
$response = Invoke-RestMethod -Uri "https://api.github.com/repos/FuckingNode/FuckingNode/releases/latest"
2223
$asset = $response.assets | Where-Object { $_.name -notlike "*.asc" -and $_.name -like "*.exe" }
2324
if (-not $asset) {
2425
Throw "No .exe file found in the latest release."
2526
}
26-
Write-Host "Fetched."
27+
Write-Output "Fetched."
2728
return $asset.browser_download_url
2829
}
2930
catch {
@@ -49,7 +50,7 @@ Function Get-LatestReleaseUrl {
4950
# creates a .bat shortcut to allow for fknode to exist alongside fuckingnode in the CLI
5051
Function New-Shortcuts {
5152
try {
52-
Write-Host "Creating shortcuts for CLI..."
53+
Write-Output "Creating shortcuts for CLI..."
5354

5455
# all aliases should be
5556
# (appName).exe <a command> [ANY ARGS PASSED]
@@ -86,7 +87,7 @@ Function New-Shortcuts {
8687
$batContent = "@echo off`n%~dp0$($appName).exe $cmd %*"
8788
$batPath = Join-Path -Path $INSTALL_DIR -ChildPath "$name.bat"
8889
Set-Content -Path $batPath -Value $batContent -Encoding ASCII
89-
Write-Host "Shortcut created successfully at $batPath"
90+
Write-Output "Shortcut created successfully at $batPath"
9091
}
9192
}
9293
catch {
@@ -101,14 +102,14 @@ Function Install-App {
101102
[string]$url
102103
)
103104
try {
104-
Write-Host "Downloading from $url..."
105+
Write-Output "Downloading from $url..."
105106

106107
if (-not (Test-Path $INSTALL_DIR)) {
107108
New-Item -ItemType Directory -Path $INSTALL_DIR | Out-Null
108109
}
109110

110111
Invoke-WebRequest -Uri $url -OutFile $EXE_PATH
111-
Write-Host "Downloaded successfully to $EXE_PATH"
112+
Write-Output "Downloaded successfully to $EXE_PATH"
112113
}
113114
catch {
114115
Throw "Failed to download or save the file: $_"
@@ -176,7 +177,7 @@ function Get-Env {
176177
# Function: Add App to PATH
177178
Function Add-AppToPath {
178179
try {
179-
Write-Host "Adding shorthand to PATH..."
180+
Write-Output "Adding shorthand to PATH..."
180181

181182
if ([string]::IsNullOrWhiteSpace($INSTALL_DIR)) {
182183
Throw "Install DIR is undefined or empty."
@@ -189,10 +190,10 @@ Function Add-AppToPath {
189190
$Path += $INSTALL_DIR
190191
Write-Env -Key 'Path' -Value ($Path -join ';')
191192
$env:PATH = $Path -join ';'
192-
Write-Host "Added $INSTALL_DIR to PATH"
193+
Write-Output "Added $INSTALL_DIR to PATH"
193194
}
194195
else {
195-
Write-Host "'${INSTALL_DIR}' is already in your PATH."
196+
Write-Output "'${INSTALL_DIR}' is already in your PATH."
196197
}
197198
}
198199
catch {
@@ -203,23 +204,23 @@ Function Add-AppToPath {
203204

204205
Function Installer {
205206
try {
206-
Write-Host "Hi! We'll install $($APP_NAME.CASED) for you. Just a sec!"
207+
Write-Output "Hi! We'll install $($APP_NAME.CASED) for you. Just a sec!"
207208
Remove-IfNeeded
208209
Install-App -url (Get-LatestReleaseUrl)
209210
Add-AppToPath
210-
Write-Host "You may have seen our documentation mention shortcuts like 'fknode', 'fkn', 'fkclean'..."
211-
Write-Host "These are made by creating a bunch of scripts (fknode.bat, fkn.bat...) next to the main installation."
212-
Write-Host "We highly recommend them, but JUST IN CASE they conflicted with any other local command, we let you choose."
211+
Write-Output "You may have seen our documentation mention shortcuts like 'fknode', 'fkn', 'fkclean'..."
212+
Write-Output "These are made by creating a bunch of scripts (fknode.bat, fkn.bat...) next to the main installation."
213+
Write-Output "We highly recommend them, but JUST IN CASE they conflicted with any other local command, we let you choose."
213214

214215
$response = Read-Host "Do you wish to create these shortcuts? [Y/N]"
215216

216217
if ($response -match '^[Yy]$') {
217218
New-Shortcuts
218219
}
219220
else {
220-
Write-Host "Okay, we WON'T create shortcuts. Beware, as documentation and help menus might still use them to refer to commands."
221+
Write-Output "Okay, we WON'T create shortcuts. Beware, as documentation and help menus might still use them to refer to commands."
221222
}
222-
Write-Host "Installed successfully! Restart your terminal for it to work."
223+
Write-Output "Installed successfully! Restart your terminal for it to work."
223224
}
224225
catch {
225226
Write-Error $_

0 commit comments

Comments
 (0)