fix(setup): Fix setup.ps1 to check Get-Acl exists
* `Get-Acl` not found in Linux Powershell version, so only call it if it exists.
This commit is contained in:
parent
c7e513634d
commit
2f0ad4cc8c
1 changed files with 23 additions and 10 deletions
|
@ -58,17 +58,30 @@ catch [System.Management.Automation.CommandNotFoundException] {
|
||||||
Test-Git-Config -Option "user.name" -ErrMsg "Git username not set!`nRun: git config --global user.name 'My Name'"
|
Test-Git-Config -Option "user.name" -ErrMsg "Git username not set!`nRun: git config --global user.name 'My Name'"
|
||||||
Test-Git-Config -Option "user.email" -ErrMsg "Git email not set!`nRun: git config --global user.email 'example@myemail.com'"
|
Test-Git-Config -Option "user.email" -ErrMsg "Git email not set!`nRun: git config --global user.email 'example@myemail.com'"
|
||||||
|
|
||||||
$permission = (Get-Acl $pwd).Access |
|
function Test-CommandExists {
|
||||||
?{$_.IdentityReference -match $env:UserName `
|
param ($command)
|
||||||
|
|
||||||
|
$oldPreference = $ErrorActionPreference
|
||||||
|
$ErrorActionPreference = ‘stop’
|
||||||
|
|
||||||
|
try {
|
||||||
|
if(Get-Command $command){ return $true }
|
||||||
|
} Catch { return $false }
|
||||||
|
Finally { $ErrorActionPreference=$oldPreference }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Test-CommandExists Get-Acl) {
|
||||||
|
$permission = (Get-Acl $pwd).Access |
|
||||||
|
?{$_.IdentityReference -match $env:UserName `
|
||||||
-and $_.FileSystemRights -match "FullControl" `
|
-and $_.FileSystemRights -match "FullControl" `
|
||||||
-or $_.FileSystemRights -match "Write" } |
|
-or $_.FileSystemRights -match "Write" } |
|
||||||
|
|
||||||
Select IdentityReference,FileSystemRights
|
Select IdentityReference,FileSystemRights
|
||||||
|
|
||||||
If (-Not $permission){
|
If (-Not $permission){
|
||||||
Write-Host "Sorry, you do not have write permissions in this directory."
|
Write-Host "Sorry, you do not have write permissions in this directory."
|
||||||
Write-Host "Please try running this script again from a directory that you do have write permissions for."
|
Write-Host "Please try running this script again from a directory that you do have write permissions for."
|
||||||
exit 1
|
exit 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$repo_path = "https://github.com/zmkfirmware/zmk-config-split-template.git"
|
$repo_path = "https://github.com/zmkfirmware/zmk-config-split-template.git"
|
||||||
|
|
Loading…
Reference in a new issue