From 727217fbc5833310f6412c358ac768f9416bd8e7 Mon Sep 17 00:00:00 2001 From: sitiom <56180050+sitiom@users.noreply.github.com> Date: Sun, 22 Nov 2020 09:28:21 +0800 Subject: [PATCH] Add PowerShell install script --- tools/git-submodule/install.ps1 | 22 ++++++++++++++++++++++ tools/hg-subrepo/install.ps1 | 21 +++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 tools/git-submodule/install.ps1 create mode 100644 tools/hg-subrepo/install.ps1 diff --git a/tools/git-submodule/install.ps1 b/tools/git-submodule/install.ps1 new file mode 100644 index 0000000..6c4a9ab --- /dev/null +++ b/tools/git-submodule/install.ps1 @@ -0,0 +1,22 @@ +$ErrorActionPreference = "Stop" + +$CONFIG = "install.conf.yaml" +$DOTBOT_DIR = "dotbot" + +$DOTBOT_BIN = "bin/dotbot" +$BASEDIR = $PSScriptRoot + +Set-Location $BASEDIR +git -C $DOTBOT_DIR submodule sync --quiet --recursive +git submodule update --init --recursive $DOTBOT_DIR + +foreach ($PYTHON in ('python', 'python3', 'python2')) { + # Python redirects to Microsoft Store in Windows 10 when not installed + if (& { $ErrorActionPreference = "SilentlyContinue" + ![string]::IsNullOrEmpty((&$PYTHON -V)) + $ErrorActionPreference = "Stop" }) { + &$PYTHON $(Join-Path $BASEDIR $DOTBOT_DIR $DOTBOT_BIN) -d $BASEDIR -c $CONFIG $Args + return + } +} +Write-Error "Error: Cannot find Python." diff --git a/tools/hg-subrepo/install.ps1 b/tools/hg-subrepo/install.ps1 new file mode 100644 index 0000000..235addf --- /dev/null +++ b/tools/hg-subrepo/install.ps1 @@ -0,0 +1,21 @@ +$ErrorActionPreference = "Stop" + +$CONFIG = "install.conf.yaml" +$DOTBOT_DIR = "dotbot" + +$DOTBOT_BIN = "bin/dotbot" +$BASEDIR = $PSScriptRoot + +Set-Location $BASEDIR + +Set-Location $DOTBOT_DIR && git submodule update --init --recursive +foreach ($PYTHON in ('python', 'python3', 'python2')) { + # Python redirects to Microsoft Store in Windows 10 when not installed + if (& { $ErrorActionPreference = "SilentlyContinue" + ![string]::IsNullOrEmpty((&$PYTHON -V)) + $ErrorActionPreference = "Stop" }) { + &$PYTHON $(Join-Path $BASEDIR $DOTBOT_DIR $DOTBOT_BIN) -d $BASEDIR -c $CONFIG $Args + return + } +} +Write-Error "Error: Cannot find Python."