Skip to content

Commit e89edb8

Browse files
committed
Forcefully kill FuckingNode on Windows for the updater to work
1 parent d395390 commit e89edb8

3 files changed

Lines changed: 45 additions & 20 deletions

File tree

docs/about/roadmap.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ This page also lists all minor and major releases since 2.X. Patches aren't list
88

99
**Patch releases are made on a weekly basis, and feature releases are made on a monthly basis.** You can check more info in [our release schedule document here](https://github.com/FuckingNode/FuckingNode/blob/master/RELEASE_SCHEDULE.md).
1010

11-
## 5.X (Released)
11+
## 5.X
12+
13+
## Version 5.0 (Released)
1214

1315
- [x] Improve `setup`.
1416
- [x] Add more setups (LICENSEs, gitignores, etc...).

docs/install.ps1

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,34 @@ $APP_NAME = @{
77
$INSTALL_DIR = "C:\$($APP_NAME.CASED)"
88
$EXE_PATH = Join-Path -Path $INSTALL_DIR -ChildPath "$($APP_NAME.CLI).exe"
99

10-
Function Remove-IfNeeded() {
11-
if ($null -ne $args[0] -as [double]) {
12-
Stop-Process -Id $args[0] -Force
10+
# DETACH PROCESS
11+
if ($args[1] -ne "NA") {
12+
# powershell path (pwsh on PS Core, powershell on Windows PS)
13+
$exe = if ($PSVersionTable.PSEdition -eq "Core") { "pwsh" } else { "powershell" }
14+
$script = $PSCommandPath
15+
16+
Start-Process -FilePath $exe -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$script`" _ NA"
17+
# quit parent
18+
exit
19+
}
20+
21+
Start-Sleep -Seconds 1
22+
Write-Output "(Check... DETACHED $PID)"
23+
24+
Function Remove-IfNeeded {
25+
if ($args.Count -eq 1) {
26+
$procId = $args[0] -as [int]
27+
}
28+
else {
29+
$proc = Get-Process -Name $APP_NAME.CLI -ErrorAction SilentlyContinue | Select-Object -First 1
30+
if ($proc) { $procId = $proc.Id }
31+
}
32+
33+
if ($procId) {
34+
Write-Output "FuckingNode found to be running. Removing existing install (PID $procId) for updating."
35+
Stop-Process -Id $procId -Force
1336
Remove-Item $EXE_PATH -Force
14-
}
37+
}
1538
}
1639

1740
# get latest release URL
@@ -49,7 +72,7 @@ Function Get-LatestReleaseUrl {
4972
# creates a .bat shortcut to allow for fknode to exist alongside fuckingnode in the CLI
5073
Function New-Shortcuts {
5174
try {
52-
Write-Host "Creating shortcuts for CLI..."
75+
Write-Output "Creating shortcuts for CLI..."
5376

5477
# all aliases should be
5578
# (appName).exe <a command> [ANY ARGS PASSED]
@@ -86,7 +109,7 @@ Function New-Shortcuts {
86109
$batContent = "@echo off`n%~dp0$($appName).exe $cmd %*"
87110
$batPath = Join-Path -Path $INSTALL_DIR -ChildPath "$name.bat"
88111
Set-Content -Path $batPath -Value $batContent -Encoding ASCII
89-
Write-Host "Shortcut created successfully at $batPath"
112+
Write-Output "Shortcut created successfully at $batPath"
90113
}
91114
}
92115
catch {
@@ -101,17 +124,17 @@ Function Install-App {
101124
[string]$url
102125
)
103126
try {
104-
Write-Host "Downloading from $url..."
127+
Write-Output "Downloading from $url..."
105128

106129
if (-not (Test-Path $INSTALL_DIR)) {
107130
New-Item -ItemType Directory -Path $INSTALL_DIR | Out-Null
108131
}
109132

110133
Invoke-WebRequest -Uri $url -OutFile $EXE_PATH
111-
Write-Host "Downloaded successfully to $EXE_PATH"
134+
Write-Output "Downloaded successfully to $EXE_PATH"
112135
}
113136
catch {
114-
Throw "Failed to download or save the file: $_"
137+
Throw "Failed to download fuckingnode.exe: $_"
115138
}
116139
}
117140

@@ -176,7 +199,7 @@ function Get-Env {
176199
# Function: Add App to PATH
177200
Function Add-AppToPath {
178201
try {
179-
Write-Host "Adding shorthand to PATH..."
202+
Write-Output "Adding shorthand to PATH..."
180203

181204
if ([string]::IsNullOrWhiteSpace($INSTALL_DIR)) {
182205
Throw "Install DIR is undefined or empty."
@@ -189,10 +212,10 @@ Function Add-AppToPath {
189212
$Path += $INSTALL_DIR
190213
Write-Env -Key 'Path' -Value ($Path -join ';')
191214
$env:PATH = $Path -join ';'
192-
Write-Host "Added $INSTALL_DIR to PATH"
215+
Write-Output "Added $INSTALL_DIR to PATH"
193216
}
194217
else {
195-
Write-Host "'${INSTALL_DIR}' is already in your PATH."
218+
Write-Output "'${INSTALL_DIR}' is already in your PATH."
196219
}
197220
}
198221
catch {
@@ -203,23 +226,23 @@ Function Add-AppToPath {
203226

204227
Function Installer {
205228
try {
206-
Write-Host "Hi! We'll install $($APP_NAME.CASED) for you. Just a sec!"
229+
Write-Output "Hi! We'll install $($APP_NAME.CASED) for you. Just a sec!"
207230
Remove-IfNeeded
208231
Install-App -url (Get-LatestReleaseUrl)
209232
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."
233+
Write-Output "You may have seen our documentation mention shortcuts like 'fknode', 'fkn', 'fkclean'..."
234+
Write-Output "These are made by creating a bunch of scripts (fknode.bat, fkn.bat...) next to the main installation."
235+
Write-Output "We highly recommend them, but JUST IN CASE they conflicted with any other local command, we let you choose."
213236

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

216239
if ($response -match '^[Yy]$') {
217240
New-Shortcuts
218241
}
219242
else {
220-
Write-Host "Okay, we WON'T create shortcuts. Beware, as documentation and help menus might still use them to refer to commands."
243+
Write-Output "Okay, we WON'T create shortcuts. Beware, as documentation and help menus might still use them to refer to commands."
221244
}
222-
Write-Host "Installed successfully! Restart your terminal for it to work."
245+
Write-Output "Installed successfully! Restart your terminal for it to work."
223246
}
224247
catch {
225248
Write-Error $_

docs/manual/fknode-yaml.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ It's something like this:
215215
Info:
216216

217217
- All commands run in order and block each other.
218-
- Colons are not required, but double colons are accepted. `~foo` is equal to `~"foo"`.
218+
- Colons are not required. Single and double colons are accepted. `~foo` is equal to `~"foo"` and `~'foo'`.
219219
- Cmd output is not live, meaning if a command writes to the stdout step by step, you won't see that until it ends execution.
220220

221221
You can use CmdSets for the following project settings:

0 commit comments

Comments
 (0)