update_settings.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. DEFAULT_TRUE="'default': true"
  2. DEFAULT_FALSE="'default': false"
  3. TELEMETRY_ENABLE="'telemetry.enableTelemetry':"
  4. TELEMETRY_CRASH_REPORTER="'telemetry.enableCrashReporter':"
  5. #include common functions
  6. . ../utils.sh
  7. update_setting () {
  8. local FILENAME="$2"
  9. # check that the file exists
  10. if [ ! -f $FILENAME ]; then
  11. echo "File to update setting in does not exist ${FILENAME}"
  12. return
  13. fi
  14. # go through lines of file, looking for block that contains setting
  15. local SETTING="$1"
  16. local LINE_NUM=0
  17. while read -r line; do
  18. local LINE_NUM=$(( $LINE_NUM + 1 ))
  19. if [[ $line == *"$SETTING"* ]]; then
  20. local IN_SETTING=1
  21. fi
  22. if [[ $line == *"$DEFAULT_TRUE"* && "$IN_SETTING" == "1" ]]; then
  23. local FOUND=1
  24. break
  25. fi
  26. done < $FILENAME
  27. if [[ "$FOUND" != "1" ]]; then
  28. echo "$DEFAULT_TRUE not found for setting $SETTING in file $FILENAME"
  29. return
  30. fi
  31. # construct line-aware replacement string
  32. local DEFAULT_TRUE_TO_FALSE="${LINE_NUM}s/${DEFAULT_TRUE}/${DEFAULT_FALSE}/"
  33. replace "$DEFAULT_TRUE_TO_FALSE" $FILENAME
  34. }
  35. update_setting "$TELEMETRY_ENABLE" src/vs/platform/telemetry/common/telemetryService.ts
  36. update_setting "$TELEMETRY_CRASH_REPORTER" src/vs/workbench/electron-sandbox/desktop.contribution.ts