From 90be397b83f4c056ceb605735e1061d57f2bf8a3 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Mon, 27 Apr 2020 19:15:18 +0000 Subject: [PATCH] get node install working in windows --- node/node.bat | 27 +++++++++++++++++++-------- pathman/pathman.bat | 19 +++++++++++++++++++ webi/webi.bat | 2 ++ webi/webinstall.bat | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 78 insertions(+), 8 deletions(-) create mode 100644 pathman/pathman.bat create mode 100644 webi/webi.bat create mode 100644 webi/webinstall.bat diff --git a/node/node.bat b/node/node.bat index 6e3aaf8..74b1319 100644 --- a/node/node.bat +++ b/node/node.bat @@ -1,10 +1,21 @@ -mkdir %userprofile%\.local -mkdir %userprofile%\.local\opt +setlocal +@echo off +pushd "%userprofile%\.local\opt" || goto :error + powershell $ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest https://nodejs.org/dist/v12.16.2/node-v12.16.2-win-x64.zip -OutFile node-v12.16.2-win-x64.zip || goto :error + rem Windows BSD-tar handles zip. Imagine that. + tar xf node-v12.16.2-win-x64.zip || goto :error + dir + rename node-v12.16.2-win-x64 node-v12.16.2 || goto :error + rmdir node-v12.16.2-win-x64 + del node-v12.16.2-win-x64.zip || goto :error +popd || goto :error -pushd %userprofile%\.local\opt - powershell $ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest https://nodejs.org/dist/v12.16.2/node-v12.16.2-win-x64.zip -OutFile node-v12.16.2-win-x64.zip - tar xf node-v12.16.2-win-x64.zip - move node-v12.16.2-win-x64 node-v12.16.2 -popd +rem make npm not act stupid about which node to use... ugh (this should be the default) +"%userprofile%\.local\opt\node-v12.16.2\npm.cmd" --scripts-prepend-node-path=true config set scripts-prepend-node-path true +pathman add .local\opt\node-v12.16.2 || goto :error -pathman add %userprofile%\.local\opt\node-v12.16.2\bin +goto :EOF + +:error +echo Failed with error #%errorlevel%. +exit /b %errorlevel% diff --git a/pathman/pathman.bat b/pathman/pathman.bat new file mode 100644 index 0000000..67ae251 --- /dev/null +++ b/pathman/pathman.bat @@ -0,0 +1,19 @@ +pushd "%userprofile%" || goto :error + IF NOT EXIST .local ( + mkdir .local || goto :error + ) + IF NOT EXIST .local\bin ( + mkdir .local\bin || goto :error + ) + + pushd .local\bin || goto :error + rem TODO %PROCESSOR_ARCH% + powershell $ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest "https://rootprojects.org/pathman/dist/windows/amd64/pathman.exe" -OutFile pathman.exe || goto :error + popd || goto :error +popd + +goto :EOF + +:error +echo Failed with error #%errorlevel%. +exit /b %errorlevel% diff --git a/webi/webi.bat b/webi/webi.bat new file mode 100644 index 0000000..30da18b --- /dev/null +++ b/webi/webi.bat @@ -0,0 +1,2 @@ +rem do nothing because this is a special case +rem due to windows complexities, webinstall.bat is always installed to ~/.local/bin/webi.bat diff --git a/webi/webinstall.bat b/webi/webinstall.bat new file mode 100644 index 0000000..cac5c6d --- /dev/null +++ b/webi/webinstall.bat @@ -0,0 +1,38 @@ +@echo off +pushd "%userprofile%" || goto :error + IF NOT EXIST .local ( + mkdir .local || goto :error + ) + IF NOT EXIST .local\bin ( + mkdir .local\bin || goto :error + ) + IF NOT EXIST .local\opt ( + mkdir .local\opt || goto :error + ) + + pushd .local\bin || goto :error + if NOT EXIST pathman.exe ( + echo updating PATH management + powershell $ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest https://webinstall.dev/pathman/pathman.bat -OutFile pathman-setup.bat || goto :error + call .\pathman-setup.bat || goto :error + del pathman-setup.bat || goto :error + rem TODO there's rumor of a windows tool called 'pathman' that does the same thing? + pathman add "%userprofile%\.local\bin" || goto :error + ) + popd || goto :error + + echo downloading and installing %1 + powershell $ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest https://webinstall.dev/%1/%1.bat -OutFile %1-webinstall.bat || goto :error + + rem TODO only add if it's not in there already + PATH .local\bin;%PATH% + + call %1-webinstall.bat || goto :error + del %1-webinstall.bat || goto :error +popd + +goto :EOF + +:error +echo Failed with error #%errorlevel%. +exit /b %errorlevel% -- 2.25.1