2019-04-14 16:53:09 -04:00
|
|
|
DEFAULT_TRUE="'default': true"
|
|
|
|
DEFAULT_FALSE="'default': false"
|
2021-10-19 14:55:44 -04:00
|
|
|
DEFAULT_ON="'default': TelemetryConfiguration.ON"
|
|
|
|
DEFAULT_OFF="'default': TelemetryConfiguration.OFF"
|
2019-04-14 16:53:09 -04:00
|
|
|
TELEMETRY_CRASH_REPORTER="'telemetry.enableCrashReporter':"
|
2021-10-19 14:55:44 -04:00
|
|
|
TELEMETRY_CONFIGURATION=" TelemetryConfiguration.ON"
|
2019-04-14 16:53:09 -04:00
|
|
|
|
2022-08-16 07:51:45 -04:00
|
|
|
# include common functions
|
2021-07-21 16:49:00 -04:00
|
|
|
. ../utils.sh
|
2019-04-14 16:53:09 -04:00
|
|
|
|
|
|
|
update_setting () {
|
2022-06-05 15:30:23 -04:00
|
|
|
local FILENAME="${2}"
|
2019-04-14 16:53:09 -04:00
|
|
|
# check that the file exists
|
2022-06-05 15:30:23 -04:00
|
|
|
if [ ! -f "${FILENAME}" ]; then
|
2019-04-14 16:53:09 -04:00
|
|
|
echo "File to update setting in does not exist ${FILENAME}"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
# go through lines of file, looking for block that contains setting
|
2022-06-05 15:30:23 -04:00
|
|
|
local SETTING="${1}"
|
2019-04-14 16:53:09 -04:00
|
|
|
local LINE_NUM=0
|
|
|
|
while read -r line; do
|
|
|
|
local LINE_NUM=$(( $LINE_NUM + 1 ))
|
2022-06-05 15:30:23 -04:00
|
|
|
if [[ "${line}" == *"${SETTING}"* ]]; then
|
2019-04-14 16:53:09 -04:00
|
|
|
local IN_SETTING=1
|
|
|
|
fi
|
2022-06-05 15:30:23 -04:00
|
|
|
if [[ ("${line}" == *"${DEFAULT_TRUE}"* || "${line}" == *"${DEFAULT_ON}"*) && "${IN_SETTING}" == "1" ]]; then
|
2019-04-14 16:53:09 -04:00
|
|
|
local FOUND=1
|
|
|
|
break
|
|
|
|
fi
|
2022-06-05 15:30:23 -04:00
|
|
|
done < "${FILENAME}"
|
2019-04-14 16:53:09 -04:00
|
|
|
|
2022-06-05 15:30:23 -04:00
|
|
|
if [[ "${FOUND}" != "1" ]]; then
|
|
|
|
echo "${DEFAULT_TRUE} not found for setting ${SETTING} in file ${FILENAME}"
|
2019-04-14 16:53:09 -04:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
# construct line-aware replacement string
|
2022-06-05 15:30:23 -04:00
|
|
|
if [[ "${line}" == *"${DEFAULT_TRUE}"* ]]; then
|
2021-10-19 14:55:44 -04:00
|
|
|
local DEFAULT_TRUE_TO_FALSE="${LINE_NUM}s/${DEFAULT_TRUE}/${DEFAULT_FALSE}/"
|
2022-04-07 14:30:38 -04:00
|
|
|
else
|
2021-10-19 14:55:44 -04:00
|
|
|
local DEFAULT_TRUE_TO_FALSE="${LINE_NUM}s/${DEFAULT_ON}/${DEFAULT_OFF}/"
|
|
|
|
fi
|
2022-04-07 14:30:38 -04:00
|
|
|
|
2022-06-05 15:30:23 -04:00
|
|
|
replace "${DEFAULT_TRUE_TO_FALSE}" "${FILENAME}"
|
2019-04-14 16:53:09 -04:00
|
|
|
}
|
|
|
|
|
2022-06-05 15:30:23 -04:00
|
|
|
update_setting "${TELEMETRY_CRASH_REPORTER}" src/vs/workbench/electron-sandbox/desktop.contribution.ts
|
|
|
|
update_setting "${TELEMETRY_CONFIGURATION}" src/vs/platform/telemetry/common/telemetryService.ts
|