diff --git a/install.ps1 b/install.ps1 index 2fad4f3..23330cc 100644 --- a/install.ps1 +++ b/install.ps1 @@ -718,7 +718,7 @@ $customFileApplied = $false function Apply-CustomFile() { Param ( [Parameter(Mandatory=$true, Position=0)] - [string] $gitDir, + [string] $profilePath, [Parameter(Mandatory=$true, Position=1)] [string] $targetFile, [Parameter(Mandatory=$true, Position=2)] @@ -727,6 +727,7 @@ function Apply-CustomFile() { [string] $otherCustom = "" ) + $local:gitDir = "${profilePath}\chrome\.git" if ( Test-Path -Path "${customFile}" -PathType leaf ) { $global:customFileApplied = $true @@ -735,7 +736,12 @@ function Apply-CustomFile() { } if ( "${customReset}" -eq $true ) { - git --git-dir "${gitDir}" reset --hard HEAD + if ( "${targetFile}" -like "*user.js" ) { + Copy-Item -Path "${customFile}" -Destination "${targetFile}" -Force + } + else { + git --git-dir "${gitDir}" --quiet checkout HEAD -- "${targetFile}" + } } if ( "${customAppend}" -eq $true ) { # Apply without duplication @@ -745,23 +751,22 @@ function Apply-CustomFile() { } } elseif ( "${otherCustom}" -ne "" ) { - Apply-CustomFile "${gitDir}" "${targetFile}" "${otherCustom}" + Apply-CustomFile "${profilePath}" "${targetFile}" "${otherCustom}" } } function Apply-CustomFiles() { foreach ( $profilePath in $global:firefoxProfilePaths ) { - $local:LEPTONGITPATH="${profilePath}\chrome\.git" foreach ( $customFile in $global:customFiles ) { $local:targetFile = $customFile.Replace("-overrides", "") if ( "${customFile}" -eq "user-overrides.js" ) { $local:targetPath = "${profilePath}\${targetFile}" $local:customPath = "${profilePath}\user-overrides.js" $local:otherCustomPath = "${profilePath}\chrome\user-overrides.js" - Apply-CustomFile "${LEPTONGITPATH}" "${targetPath}" "${customPath}" "${otherCustomPath}" + Apply-CustomFile "${profilePath}" "${targetPath}" "${customPath}" "${otherCustomPath}" } else { - Apply-CustomFile "${LEPTONGITPATH}" "${profilePath}\chrome\${targetFile}" "${profilePath}\chrome\${customFile}" + Apply-CustomFile "${profilePath}" "${profilePath}\chrome\${targetFile}" "${profilePath}\chrome\${customFile}" } } } diff --git a/install.sh b/install.sh index 7416b27..ad8c568 100755 --- a/install.sh +++ b/install.sh @@ -695,11 +695,12 @@ set_custom_method() { customFileApplied="" apply_custom_file() { - local gitDir=$1 + local profilePath=$1 local targetFile=$2 local customFile=$3 local otherCustom=$4 + local gitDir="${profilePath}/chrome/.git" if [ -f "${customFile}" ]; then customFileApplied="true" @@ -708,7 +709,11 @@ apply_custom_file() { fi if [ "${customReset}" == "true" ]; then - git --git-dir "${gitDir}" reset --hard HEAD + if [[ "${targetFile}" == *"user.js" ]]; then + \cp -f "${profilePath}/chrome/user.js" "${targetFile}" + else + git --git-dir "${gitDir}" --quiet checkout HEAD -- "${targetFile}" + fi fi if [ "${customAppend}" == "true" ]; then # Apply without duplication @@ -717,22 +722,21 @@ apply_custom_file() { fi fi elif [ -n "${otherCustom}" ]; then - apply_custom_file "${gitDir}" "${targetFile}" "${otherCustom}" + apply_custom_file "${profilePath}" "${targetFile}" "${otherCustom}" fi } apply_custom_files() { for profilePath in "${firefoxProfilePaths[@]}"; do - local LEPTONGITPATH="${profilePath}/chrome/.git" for customFile in "${customFiles[@]}"; do local targetFile="${customFile//-overrides/}" if [ "${customFile}" == "user-overrides.js" ]; then local targetPath="${profilePath}/${targetFile}" local customPath="${profilePath}/user-overrides.js" local otherCustomPath="${profilePath}/chrome/user-overrides.js" - apply_custom_file "${LEPTONGITPATH}" "${targetPath}" "${customPath}" "${otherCustomPath}" + apply_custom_file "${profilePath}" "${targetPath}" "${customPath}" "${otherCustomPath}" else - apply_custom_file "${LEPTONGITPATH}" "${profilePath}/chrome/${targetFile}" "${profilePath}/chrome/${customFile}" + apply_custom_file "${profilePath}" "${profilePath}/chrome/${targetFile}" "${profilePath}/chrome/${customFile}" fi done done