From c72ab0cd3c504003c96e1cc8fcda2f545f5ac5b7 Mon Sep 17 00:00:00 2001 From: Isaac Shoebottom Date: Thu, 2 Nov 2023 12:04:35 -0300 Subject: [PATCH] Add setup script for softlinking src folder --- setup.ps1 | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 setup.ps1 diff --git a/setup.ps1 b/setup.ps1 new file mode 100644 index 0000000..3c46fe4 --- /dev/null +++ b/setup.ps1 @@ -0,0 +1,38 @@ +if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]'Administrator')) +{ + $CommandLine = "-c cd '$pwd'; & `"" + $MyInvocation.MyCommand.Path + "`"" + Start-Process powershell -Verb runas -ArgumentList $CommandLine + exit +} + +# Folder handle for the submodule src folder +$srcFolder = "typescript-template\src\" + +# Init git submodules +git submodule update --init --recursive +# Check if submodule src folder exists +if (!(Test-Path $srcFolder)) +{ + Write-Host "No submodule src folder found" + # Make a link from the src folder to the submodule src folder + New-Item -ItemType SymbolicLink -Path $srcFolder -Target src +} +elseif ((Get-Item $srcFolder).Attributes -match 'ReparsePoint') +{ + Write-Host "Submodule src folder is a soft link" + # Remove the soft link + Remove-Item $srcFolder -Recurse + + # Make a link from the src folder to the submodule src folder + New-Item -ItemType SymbolicLink -Path $srcFolder -Target src +} +else +{ + Write-Host "Submodule src folder is newly created" + # Remove the src folder + Remove-Item $srcFolder -Recurse + + # Make a link from the src folder to the submodule src folder + New-Item -ItemType SymbolicLink -Path $srcFolder -Target src +} +# Add Read-Host to see the output \ No newline at end of file