MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    1. Home
    2. TimOgden
    3. Best
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.
    T
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 6
    • Groups 0

    Posts

    Recent Best Controversial
    • RE: Storing variables to be ignored by git in a js file?

      @sdetweil Ok, implementing @sdetweil 's suggestions, I have created a working version. This is my workflow.

      // config/dictionary.txt
      // This is a list of key-value or string-replacement pairs
      "{latitude}"    :    "40"
      "{longitude}"    :    "-70"
      
      // installers/copy-values.sh
      // sed command found here: 
      // https://unix.stackexchange.com/questions/269368/string-replacement-using-a-dictionary
      cd ~/MagicMirror
      cp config/config.model.js config/config.js
      sed '
      s|"\(.*\)"[[:blank:]]*:[[:blank:]]*"\(.*\)"|\1\
      \2|
      h
      s|.*\n||
      s|[\&/]|\\&|g
      x
      s|\n.*||
      s|[[\.*^$/]|\\&|g
      G
      s|\(.*\)\n\(.*\)|s/\1/\2/g|
      ' config/dictionary.txt | sed -i -f - config/config.js
      
      DISPLAY=:0 npm start
      

      Now I can have separate dictionary.txt files on both machines for any local important information, which I will add to .gitignore. I will continue to modify config.model.js, and config.model.js will be copied and cleaned up with all the right values before every start of the mirror.

      posted in Troubleshooting
      T
      TimOgden
    • 1 / 1