Merge pull request #256 from careyk007/check_directory_write_permissions_in_setup_script

Exit setup if no write permissions in directory
This commit is contained in:
Pete Johanson 2020-10-10 20:09:55 -04:00 committed by GitHub
commit a7e8655287
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

15
docs/static/setup.ps1 vendored
View File

@ -57,7 +57,20 @@ 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.email" -ErrMsg "Git email not set!`nRun: git config --global user.name '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 |
?{$_.IdentityReference -match $env:UserName `
-and $_.FileSystemRights -match "FullControl" `
-or $_.FileSystemRights -match "Write" } |
Select IdentityReference,FileSystemRights
If (-Not $permission){
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."
exit 1
}
$repo_path = "https://github.com/zmkfirmware/zmk-config-split-template.git"

View File

@ -22,6 +22,13 @@ check_exists "command -v curl" "curl is not installed, and is required for this
check_exists "git config user.name" "Git username not set!\nRun: git config --global user.name 'My Name'"
check_exists "git config user.email" "Git email not set!\nRun: git config --global user.email 'example@myemail.com'"
# Check to see if the user has write permissions in this directory to prevent a cryptic error later on
if [ ! -w `pwd` ]; then
echo 'Sorry, you do not have write permissions in this directory.';
echo 'Please try running this script again from a directory that you do have write permissions for.';
exit 1
fi
repo_path="https://github.com/zmkfirmware/zmk-config-split-template.git"
title="ZMK Config Setup:"