-
-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #130 from nonepork/main
Added support for windows.
- Loading branch information
Showing
4 changed files
with
183 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
param( | ||
[switch] | ||
$AllUsers | ||
) | ||
|
||
function FolderIsInPATH($Path_to_directory) { | ||
return ([Environment]::GetEnvironmentVariable("PATH", "User") -split ';').TrimEnd('\') -contains $Path_to_directory.TrimEnd('\') | ||
} | ||
|
||
Write-Host -ForegroundColor DarkRed " ______ __ __ " | ||
Write-Host -ForegroundColor Red " / \ / |/ | " | ||
Write-Host -ForegroundColor DarkYellow " _______ __ __ ______ ______ ______ /`$`$`$`$`$`$ |`$`$/ `$`$ | ______ " | ||
Write-Host -ForegroundColor Yellow " / |/ | / | / \ / \ / \ `$`$ |_ `$`$/ / |`$`$ | / \ " | ||
Write-Host -ForegroundColor DarkGreen "/`$`$`$`$`$`$`$/ `$`$ | `$`$ |/`$`$`$`$`$`$ |/`$`$`$`$`$`$ |/`$`$`$`$`$`$ |`$`$ | `$`$ |`$`$ |/`$`$`$`$`$`$ |" | ||
Write-Host -ForegroundColor Green "`$`$ \ `$`$ | `$`$ |`$`$ | `$`$ |`$`$ `$`$ |`$`$ | `$`$/ `$`$`$`$/ `$`$ |`$`$ |`$`$ `$`$ |" | ||
Write-Host -ForegroundColor DarkBlue " `$`$`$`$`$`$ |`$`$ \__`$`$ |`$`$ |__`$`$ |`$`$`$`$`$`$`$`$/ `$`$ | `$`$ | `$`$ |`$`$ |`$`$`$`$`$`$`$`$/ " | ||
Write-Host -ForegroundColor Blue " `$`$/ `$`$ `$`$/ `$`$ `$`$/ `$`$ |`$`$ | `$`$ | `$`$ |`$`$ |`$`$ |" | ||
Write-Host -ForegroundColor DarkMagenta "`$`$`$`$`$`$`$/ `$`$`$`$`$`$/ `$`$`$`$`$`$`$/ `$`$`$`$`$`$`$/ `$`$/ `$`$/ `$`$/ `$`$/ `$`$`$`$`$`$`$/ " | ||
Write-Host -ForegroundColor Magenta " `$`$ | " | ||
Write-Host -ForegroundColor DarkRed " `$`$ | " | ||
Write-Host -ForegroundColor Red " `$`$/ " | ||
Write-Host "" | ||
|
||
$package = "superfile" | ||
$version = "1.1.2" | ||
|
||
$installInstructions = @' | ||
This installer is only available for Windows. | ||
If you're looking for installation instructions for your operating system, | ||
please visit the following link: | ||
'@ | ||
if ($IsMacOS) { | ||
Write-Host @" | ||
$installInstructions | ||
https://github.com/MHNightCat/superfile?tab=readme-ov-file#installation | ||
"@ | ||
exit | ||
} | ||
if ($IsLinux) { | ||
Write-Host @" | ||
$installInstructions | ||
https://github.com/MHNightCat/superfile?tab=readme-ov-file#installation | ||
"@ | ||
exit | ||
} | ||
|
||
$arch = (Get-CimInstance -Class Win32_Processor -Property Architecture).Architecture | Select-Object -First 1 | ||
switch ($arch) { | ||
5 { $arch = "arm64" } # ARM | ||
9 { | ||
if ([Environment]::Is64BitOperatingSystem) { | ||
$arch = "amd64" | ||
} | ||
} | ||
12 { $arch = "arm64" } # Surface Pro X | ||
} | ||
if ([string]::IsNullOrEmpty($arch)) { | ||
Write-Host @" | ||
The installer for system arch ($arch) is not available. | ||
"@ | ||
exit | ||
} | ||
$filename = "$package-windows-v$version-$arch.zip" | ||
|
||
Write-Host "Downloading superfile..." | ||
|
||
$superfileProgramPath = [Environment]::GetFolderPath("LocalApplicationData") + "\Programs\superfile" | ||
if (-not (Test-Path $superfileProgramPath)) { | ||
New-Item -Path $superfileProgramPath -ItemType Directory -Verbose:$false | Out-Null | ||
} else { | ||
Write-Host "Folder $superfileProgramPath already exists. :/" | ||
exit | ||
} | ||
$url = "https://github.com/MHNightCat/superfile/releases/download/$version/$filename" | ||
Invoke-WebRequest -OutFile "$superfileProgramPath\$filename" $url | ||
|
||
Write-Host "Extracting compressed file..." | ||
|
||
try { | ||
Expand-Archive -Path "$superfileProgramPath\$filename" -DestinationPath $superfileProgramPath | ||
Remove-Item -Path "$superfileProgramPath\$filename" | ||
} catch { | ||
Write-Host "An error occurred: $_" | ||
exit | ||
} | ||
if (-not (FolderIsInPATH "$superfileProgramPath\spf.bat")) { | ||
$envPath = [Environment]::GetEnvironmentVariable("PATH", "User") | ||
$newPath = "$superfileProgramPath\spf.bat" | ||
$updatedPath = $envPath + ";" + $newPath | ||
[Environment]::SetEnvironmentVariable("PATH", $updatedPath, "User") | ||
} | ||
|
||
Write-Host @' | ||
Done! | ||
Restart you terminal, and for the love of Get-Command | ||
Take a look at tutorial :) | ||
https://github.com/MHNightCat/superfile/wiki/Tutorial | ||
'@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
REM God have mercy on what I'm about to do | ||
chcp 65001 & spf-executable.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
param( | ||
[switch] | ||
$AllUsers | ||
) | ||
|
||
function FolderIsInPATH($Path_to_directory) { | ||
return ([Environment]::GetEnvironmentVariable("PATH", "User") -split ';').TrimEnd('\') -contains $Path_to_directory.TrimEnd('\') | ||
} | ||
|
||
Write-Host -ForegroundColor DarkRed " ______ __ __ " | ||
Write-Host -ForegroundColor Red " / \ / |/ | " | ||
Write-Host -ForegroundColor DarkYellow " _______ __ __ ______ ______ ______ /`$`$`$`$`$`$ |`$`$/ `$`$ | ______ " | ||
Write-Host -ForegroundColor Yellow " / |/ | / | / \ / \ / \ `$`$ |_ `$`$/ / |`$`$ | / \ " | ||
Write-Host -ForegroundColor DarkGreen "/`$`$`$`$`$`$`$/ `$`$ | `$`$ |/`$`$`$`$`$`$ |/`$`$`$`$`$`$ |/`$`$`$`$`$`$ |`$`$ | `$`$ |`$`$ |/`$`$`$`$`$`$ |" | ||
Write-Host -ForegroundColor Green "`$`$ \ `$`$ | `$`$ |`$`$ | `$`$ |`$`$ `$`$ |`$`$ | `$`$/ `$`$`$`$/ `$`$ |`$`$ |`$`$ `$`$ |" | ||
Write-Host -ForegroundColor DarkBlue " `$`$`$`$`$`$ |`$`$ \__`$`$ |`$`$ |__`$`$ |`$`$`$`$`$`$`$`$/ `$`$ | `$`$ | `$`$ |`$`$ |`$`$`$`$`$`$`$`$/ " | ||
Write-Host -ForegroundColor Blue " `$`$/ `$`$ `$`$/ `$`$ `$`$/ `$`$ |`$`$ | `$`$ | `$`$ |`$`$ |`$`$ |" | ||
Write-Host -ForegroundColor DarkMagenta "`$`$`$`$`$`$`$/ `$`$`$`$`$`$/ `$`$`$`$`$`$`$/ `$`$`$`$`$`$`$/ `$`$/ `$`$/ `$`$/ `$`$/ `$`$`$`$`$`$`$/ " | ||
Write-Host -ForegroundColor Magenta " `$`$ | " | ||
Write-Host -ForegroundColor DarkRed " `$`$ | " | ||
Write-Host -ForegroundColor Red " `$`$/ " | ||
Write-Host "" | ||
|
||
$package = "superfile" | ||
$version = "1.1.2" | ||
|
||
$installInstructions = @' | ||
This uninstaller is only available for Windows. | ||
'@ | ||
if ($IsMacOS) { | ||
Write-Host "$installInstructions" | ||
exit | ||
} | ||
if ($IsLinux) { | ||
Write-Host "$installInstructions" | ||
exit | ||
} | ||
|
||
Write-Host "Removing folder..." | ||
|
||
$superfileProgramPath = [Environment]::GetFolderPath("LocalApplicationData") + "\Programs\superfile" | ||
try { | ||
if (Test-Path $superfileProgramPath) { | ||
Remove-Item -Path $superfileProgramPath -Recurse -Force | ||
} | ||
} | ||
catch { | ||
Write-Host "An error occurred: $_" | ||
exit | ||
} | ||
|
||
Write-Host "Removing environment path..." | ||
|
||
try { | ||
if (FolderIsInPATH "$superfileProgramPath\spf.bat") { | ||
$envPath = [Environment]::GetEnvironmentVariable("PATH", "User") | ||
$updatedPath =($envPath.Split(';') | Where-Object { $_ -ne "$superfileProgramPath\spf.bat" }) -join ';' | ||
[Environment]::SetEnvironmentVariable("PATH", $updatedPath, "User") | ||
} | ||
} | ||
catch { | ||
Write-Host "An error occurred: $_" | ||
exit | ||
} | ||
|
||
Write-Host @' | ||
Uninstall Done! | ||
'@ | ||
|