adjust indentation and merge from main

This commit is contained in:
David Refoua 2024-10-17 19:46:22 +03:30
commit 4740b836f3
2 changed files with 24 additions and 18 deletions

View File

@ -187,6 +187,11 @@ exit /b
:::=============================================================================== :::===============================================================================
:::is_git_shim - Check if the directory has a git.shim file :::is_git_shim - Check if the directory has a git.shim file
:::. :::.
:::description:
:::.
::: Shim is a small helper program for Scoop that calls the executable configured in git.shim file
::: See: github.com/ScoopInstaller/Shim and github.com/cmderdev/cmder/pull/1905
:::.
:::include: :::include:
:::. :::.
::: call "$0" ::: call "$0"
@ -202,7 +207,7 @@ exit /b
:is_git_shim :is_git_shim
pushd "%~1" pushd "%~1"
:: check if there's shim - and if yes follow the path :: check if there is a shim file - if yes, read the actual executable path
setlocal enabledelayedexpansion setlocal enabledelayedexpansion
if exist git.shim ( if exist git.shim (
for /F "tokens=2 delims== " %%I in (git.shim) do ( for /F "tokens=2 delims== " %%I in (git.shim) do (

View File

@ -18,7 +18,8 @@ function readVersion($gitPath) {
} }
function isGitShim($gitPath) { function isGitShim($gitPath) {
# check if there's shim - and if yes follow the path # check if there is a shim file - if yes, read the actual executable path
# See: github.com/ScoopInstaller/Shim
if (Test-Path "${gitPath}\git.shim") { if (Test-Path "${gitPath}\git.shim") {
$shim = (get-content "${gitPath}\git.shim") $shim = (get-content "${gitPath}\git.shim")
@ -178,27 +179,27 @@ function getGitStatusSetting() {
} }
function yOrn( $question ) { function yOrn( $question ) {
Do { Do {
$Answer = Read-Host -Prompt "`n${question}? (y/n) " $Answer = Read-Host -Prompt "`n${question}? (y/n) "
} }
Until ($Answer -eq 'y' -or $Answer -eq 'n' -or $Answer -eq 'yes' -or $Answer -eq 'no') Until ($Answer -eq 'y' -or $Answer -eq 'n' -or $Answer -eq 'yes' -or $Answer -eq 'no')
return $Answer return $Answer
} }
function templateExpand($template_filename, $outfile) { function templateExpand($template_filename, $outfile) {
$template = Get-Content "$template_filename" -Raw $template = Get-Content "$template_filename" -Raw
$expanded = Invoke-Expression "@`"`r`n$template`r`n`"@" $expanded = Invoke-Expression "@`"`r`n$template`r`n`"@"
$overwrite = 'y' $overwrite = 'y'
if ((test-path "$outfile")) { if ((test-path "$outfile")) {
$overwrite = yOrn "'$outfile' already exists do you want to overwrite it" $overwrite = yOrn "'$outfile' already exists do you want to overwrite it"
} }
if ($overwrite -match 'y') { if ($overwrite -match 'y') {
$expanded | out-file -ErrorAction silentlycontinue -encoding ascii "$outfile" $expanded | out-file -ErrorAction silentlycontinue -encoding ascii "$outfile"
} else { } else {
write-host "Skipping Cmder '$shell' config generation at user request!" write-host "Skipping Cmder '$shell' config generation at user request!"
} }
} }