diff --git a/install.ps1 b/install.ps1 index 23330cc..535a5a6 100644 --- a/install.ps1 +++ b/install.ps1 @@ -720,15 +720,15 @@ function Apply-CustomFile() { [Parameter(Mandatory=$true, Position=0)] [string] $profilePath, [Parameter(Mandatory=$true, Position=1)] - [string] $targetFile, + [string] $targetPath, [Parameter(Mandatory=$true, Position=2)] - [string] $customFile, + [string] $customPath, [Parameter(Position=3)] - [string] $otherCustom = "" + [string] $otherCustomPath = "" ) $local:gitDir = "${profilePath}\chrome\.git" - if ( Test-Path -Path "${customFile}" -PathType leaf ) { + if ( Test-Path -Path "${customPath}" -PathType leaf ) { $global:customFileApplied = $true if ( "${customMethod}" -eq "" ) { @@ -736,22 +736,22 @@ function Apply-CustomFile() { } if ( "${customReset}" -eq $true ) { - if ( "${targetFile}" -like "*user.js" ) { - Copy-Item -Path "${customFile}" -Destination "${targetFile}" -Force + if ( "${targetPath}" -like "*user.js" ) { + Copy-Item -Path "${customFile}" -Destination "${targetPath}" -Force } else { - git --git-dir "${gitDir}" --quiet checkout HEAD -- "${targetFile}" + git --git-dir "${gitDir}" --quiet checkout HEAD -- "${targetPath}" } } if ( "${customAppend}" -eq $true ) { # Apply without duplication - if ( -not (Write-Output "$(Write-Output $(Get-Content -Path "${targetFile}"))" | Select-String -Pattern "$(Write-Output $(Get-Content -Path "${customFile}"))" -SimpleMatch -Quiet) ) { - Get-Content -Path "${customFile}" | Out-File -FilePath "${targetFile}" -Append + if ( -not (Write-Output "$(Write-Output $(Get-Content -Path "${targetPath}"))" | Select-String -Pattern "$(Write-Output $(Get-Content -Path "${customPath}"))" -SimpleMatch -Quiet) ) { + Get-Content -Path "${customPath}" | Out-File -FilePath "${targetPath}" -Append } } } - elseif ( "${otherCustom}" -ne "" ) { - Apply-CustomFile "${profilePath}" "${targetFile}" "${otherCustom}" + elseif ( "${otherCustomPath}" -ne "" ) { + Apply-CustomFile "${profilePath}" "${targetPath}" "${otherCustomPath}" } } diff --git a/install.sh b/install.sh index ad8c568..870f065 100755 --- a/install.sh +++ b/install.sh @@ -696,33 +696,33 @@ set_custom_method() { customFileApplied="" apply_custom_file() { local profilePath=$1 - local targetFile=$2 - local customFile=$3 - local otherCustom=$4 + local targetPath=$2 + local customPath=$3 + local otherCustomPath=$4 local gitDir="${profilePath}/chrome/.git" - if [ -f "${customFile}" ]; then - customFileApplied="true" + if [ -f "${customPath}" ]; then + customPathApplied="true" if [ -z "${customMethod}" ]; then set_custom_method fi if [ "${customReset}" == "true" ]; then - if [[ "${targetFile}" == *"user.js" ]]; then - \cp -f "${profilePath}/chrome/user.js" "${targetFile}" + if [[ "${targetPath}" == *"user.js" ]]; then + \cp -f "${profilePath}/chrome/user.js" "${targetPath}" else - git --git-dir "${gitDir}" --quiet checkout HEAD -- "${targetFile}" + git --git-dir "${gitDir}" --quiet checkout HEAD -- "${targetPath}" fi fi if [ "${customAppend}" == "true" ]; then # Apply without duplication - if ! grep -Fq "$(echo $(cat "${customFile}"))" <(echo "$(echo $(cat "${targetFile}"))"); then - cat "${customFile}" >> "${targetFile}" + if ! grep -Fq "$(echo $(cat "${customPath}"))" <(echo "$(echo $(cat "${targetPath}"))"); then + cat "${customPath}" >> "${targetPath}" fi fi - elif [ -n "${otherCustom}" ]; then - apply_custom_file "${profilePath}" "${targetFile}" "${otherCustom}" + elif [ -n "${otherCustomPath}" ]; then + apply_custom_file "${profilePath}" "${targetPath}" "${otherCustomPath}" fi }