mirror of
https://github.com/black7375/Firefox-UI-Fix.git
synced 2025-12-06 02:30:54 -08:00
Clean: Install - *File -> *Path at apply_custom_file
This commit is contained in:
parent
9e9036a380
commit
b1bd85d869
2 changed files with 23 additions and 23 deletions
22
install.ps1
22
install.ps1
|
|
@ -720,15 +720,15 @@ function Apply-CustomFile() {
|
||||||
[Parameter(Mandatory=$true, Position=0)]
|
[Parameter(Mandatory=$true, Position=0)]
|
||||||
[string] $profilePath,
|
[string] $profilePath,
|
||||||
[Parameter(Mandatory=$true, Position=1)]
|
[Parameter(Mandatory=$true, Position=1)]
|
||||||
[string] $targetFile,
|
[string] $targetPath,
|
||||||
[Parameter(Mandatory=$true, Position=2)]
|
[Parameter(Mandatory=$true, Position=2)]
|
||||||
[string] $customFile,
|
[string] $customPath,
|
||||||
[Parameter(Position=3)]
|
[Parameter(Position=3)]
|
||||||
[string] $otherCustom = ""
|
[string] $otherCustomPath = ""
|
||||||
)
|
)
|
||||||
|
|
||||||
$local:gitDir = "${profilePath}\chrome\.git"
|
$local:gitDir = "${profilePath}\chrome\.git"
|
||||||
if ( Test-Path -Path "${customFile}" -PathType leaf ) {
|
if ( Test-Path -Path "${customPath}" -PathType leaf ) {
|
||||||
$global:customFileApplied = $true
|
$global:customFileApplied = $true
|
||||||
|
|
||||||
if ( "${customMethod}" -eq "" ) {
|
if ( "${customMethod}" -eq "" ) {
|
||||||
|
|
@ -736,22 +736,22 @@ function Apply-CustomFile() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( "${customReset}" -eq $true ) {
|
if ( "${customReset}" -eq $true ) {
|
||||||
if ( "${targetFile}" -like "*user.js" ) {
|
if ( "${targetPath}" -like "*user.js" ) {
|
||||||
Copy-Item -Path "${customFile}" -Destination "${targetFile}" -Force
|
Copy-Item -Path "${customFile}" -Destination "${targetPath}" -Force
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
git --git-dir "${gitDir}" --quiet checkout HEAD -- "${targetFile}"
|
git --git-dir "${gitDir}" --quiet checkout HEAD -- "${targetPath}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( "${customAppend}" -eq $true ) {
|
if ( "${customAppend}" -eq $true ) {
|
||||||
# Apply without duplication
|
# Apply without duplication
|
||||||
if ( -not (Write-Output "$(Write-Output $(Get-Content -Path "${targetFile}"))" | Select-String -Pattern "$(Write-Output $(Get-Content -Path "${customFile}"))" -SimpleMatch -Quiet) ) {
|
if ( -not (Write-Output "$(Write-Output $(Get-Content -Path "${targetPath}"))" | Select-String -Pattern "$(Write-Output $(Get-Content -Path "${customPath}"))" -SimpleMatch -Quiet) ) {
|
||||||
Get-Content -Path "${customFile}" | Out-File -FilePath "${targetFile}" -Append
|
Get-Content -Path "${customPath}" | Out-File -FilePath "${targetPath}" -Append
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ( "${otherCustom}" -ne "" ) {
|
elseif ( "${otherCustomPath}" -ne "" ) {
|
||||||
Apply-CustomFile "${profilePath}" "${targetFile}" "${otherCustom}"
|
Apply-CustomFile "${profilePath}" "${targetPath}" "${otherCustomPath}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
24
install.sh
24
install.sh
|
|
@ -696,33 +696,33 @@ set_custom_method() {
|
||||||
customFileApplied=""
|
customFileApplied=""
|
||||||
apply_custom_file() {
|
apply_custom_file() {
|
||||||
local profilePath=$1
|
local profilePath=$1
|
||||||
local targetFile=$2
|
local targetPath=$2
|
||||||
local customFile=$3
|
local customPath=$3
|
||||||
local otherCustom=$4
|
local otherCustomPath=$4
|
||||||
|
|
||||||
local gitDir="${profilePath}/chrome/.git"
|
local gitDir="${profilePath}/chrome/.git"
|
||||||
if [ -f "${customFile}" ]; then
|
if [ -f "${customPath}" ]; then
|
||||||
customFileApplied="true"
|
customPathApplied="true"
|
||||||
|
|
||||||
if [ -z "${customMethod}" ]; then
|
if [ -z "${customMethod}" ]; then
|
||||||
set_custom_method
|
set_custom_method
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${customReset}" == "true" ]; then
|
if [ "${customReset}" == "true" ]; then
|
||||||
if [[ "${targetFile}" == *"user.js" ]]; then
|
if [[ "${targetPath}" == *"user.js" ]]; then
|
||||||
\cp -f "${profilePath}/chrome/user.js" "${targetFile}"
|
\cp -f "${profilePath}/chrome/user.js" "${targetPath}"
|
||||||
else
|
else
|
||||||
git --git-dir "${gitDir}" --quiet checkout HEAD -- "${targetFile}"
|
git --git-dir "${gitDir}" --quiet checkout HEAD -- "${targetPath}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ "${customAppend}" == "true" ]; then
|
if [ "${customAppend}" == "true" ]; then
|
||||||
# Apply without duplication
|
# Apply without duplication
|
||||||
if ! grep -Fq "$(echo $(cat "${customFile}"))" <(echo "$(echo $(cat "${targetFile}"))"); then
|
if ! grep -Fq "$(echo $(cat "${customPath}"))" <(echo "$(echo $(cat "${targetPath}"))"); then
|
||||||
cat "${customFile}" >> "${targetFile}"
|
cat "${customPath}" >> "${targetPath}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
elif [ -n "${otherCustom}" ]; then
|
elif [ -n "${otherCustomPath}" ]; then
|
||||||
apply_custom_file "${profilePath}" "${targetFile}" "${otherCustom}"
|
apply_custom_file "${profilePath}" "${targetPath}" "${otherCustomPath}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue