mirror of
https://github.com/webinstall/webi-installers.git
synced 2026-04-20 17:06:41 +00:00
switch from bat to ps1
This commit is contained in:
47
node/install.ps1
Normal file
47
node/install.ps1
Normal file
@@ -0,0 +1,47 @@
|
||||
# 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
|
||||
|
||||
echo "Remove leftover node-v* stuffs"
|
||||
Remove-Item -Path "node-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"
|
||||
Get-ChildItem "node-v*"
|
||||
|
||||
# Settle unpacked archive into place
|
||||
echo "New Name: $Env:PKG_NAME-v$Env:WEBI_VERSION"
|
||||
Get-ChildItem "node-v*" | Select -f 1 | Rename-Item -NewName "$Env:PKG_NAME-v$Env:WEBI_VERSION"
|
||||
echo "New Location: $Env:USERPROFILE\.local\opt\$Env:PKG_NAME-v$Env:WEBI_VERSION"
|
||||
Move-Item -Path "$Env:PKG_NAME-v$Env:WEBI_VERSION" -Destination "$Env:USERPROFILE\.local\opt"
|
||||
|
||||
# Exit tmp
|
||||
popd
|
||||
}
|
||||
|
||||
echo "Versioning $Env:PKG_NAME"
|
||||
Remove-Item -Path "$Env:USERPROFILE\.local\opt\node" -Recurse -ErrorAction Ignore
|
||||
Copy-Item -Path "$Env:USERPROFILE\.local\opt\$Env:PKG_NAME-v$Env:WEBI_VERSION" -Destination "$Env:USERPROFILE\.local\opt\$Env:PKG_NAME" -Recurse
|
||||
|
||||
# make npm not act stupid about which node to use... ugh (this should be the default)
|
||||
& .\.local\opt\node\npm.cmd --scripts-prepend-node-path=true config set scripts-prepend-node-path true
|
||||
|
||||
# Add to path
|
||||
& "$Env:USERPROFILE\.local\bin\pathman.exe" add .local\opt\node
|
||||
@@ -5,7 +5,7 @@ var map = {
|
||||
// OSes
|
||||
osx: 'macos',
|
||||
linux: 'linux',
|
||||
win: 'windows',
|
||||
win: 'windows', // windows
|
||||
sunos: 'sunos',
|
||||
aix: 'aix',
|
||||
// CPU architectures
|
||||
@@ -104,7 +104,7 @@ function getAllReleases(request) {
|
||||
|
||||
if ('macos' === os) {
|
||||
r.download += '-darwin';
|
||||
} else if ('win' === os) {
|
||||
} else if ('windows' === os) {
|
||||
r.download += '-win';
|
||||
} else {
|
||||
r.download += '-' + os;
|
||||
|
||||
Reference in New Issue
Block a user