From 2f21911ba0eb028e6bb34597f412540ba520896e Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Mon, 13 Jul 2020 20:18:01 +0000 Subject: [PATCH] add deno for Windows 10 --- deno/install.ps1 | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 deno/install.ps1 diff --git a/deno/install.ps1 b/deno/install.ps1 new file mode 100644 index 0000000..46c7669 --- /dev/null +++ b/deno/install.ps1 @@ -0,0 +1,44 @@ +#!/usr/bin/env pwsh + +# Fetch archive +IF (!(Test-Path -Path "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE")) +{ + # TODO: arch detection + echo "Downloading $Env:PKG_NAME from $Env:WEBI_PKG_URL to $Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE" + #Invoke-WebRequest https://nodejs.org/dist/v12.16.2/node-v12.16.2-win-x64.zip -OutFile node-v12.16.2-win-x64.zip + & curl.exe -A "$Env:WEBI_UA" -fsSL "$Env:WEBI_PKG_URL" -o "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE.part" + & move "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE.part" "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE" +} + +IF (!(Test-Path -Path "$Env:USERPROFILE\.local\opt\$Env:PKG_NAME-v$Env:WEBI_VERSION")) +{ + echo "Installing $Env:PKG_NAME" + # TODO: temp directory + + # Enter opt + pushd .local\tmp + + # Remove any leftover tmp cruft + Remove-Item -Path "deno-v*" -Recurse -ErrorAction Ignore + + # Unpack archive + # Windows BSD-tar handles zip. Imagine that. + echo "Unpacking $Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE" + & tar xf "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE" + + # Settle unpacked archive into place + echo "New Name: $Env:PKG_NAME-v$Env:WEBI_VERSION" + Get-ChildItem "deno*" | Select -f 1 | Rename-Item -NewName "$Env:PKG_NAME-v$Env:WEBI_VERSION.exe" + echo "New Location: $Env:USERPROFILE\.local\opt\$Env:PKG_NAME-v$Env:WEBI_VERSION.exe" + Move-Item -Path "$Env:PKG_NAME-v$Env:WEBI_VERSION.exe" -Destination "$Env:USERPROFILE\.local\opt" + + # Exit tmp + popd +} + +echo "Copying into '$Env:USERPROFILE\.local\bin\$Env:PKG_NAME.exe' from '$Env:USERPROFILE\.local\opt\$Env:PKG_NAME-v$Env:WEBI_VERSION.exe'" +Remove-Item -Path "$Env:USERPROFILE\.local\bin\$Env:PKG_NAME.exe" -Recurse -ErrorAction Ignore +Copy-Item -Path "$Env:USERPROFILE\.local\opt\$Env:PKG_NAME-v$Env:WEBI_VERSION.exe" -Destination "$Env:USERPROFILE\.local\bin\$Env:PKG_NAME.exe" -Recurse + +# Add to path +& "$Env:USERPROFILE\.local\bin\pathman.exe" add ~/.local/bin -- 2.25.1