Read the statement by Michael Teeuw here.
Storing variables to be ignored by git in a js file?
-
@timogden no straight forward way to do that.
you can write a script to merge your two property files into THE config.js and then launch mm
put the script in front of the npm start in installers/mm sh
which is used by pm2 to launch mm
as u noted, import doesn’t work. config.js is loaded into the browser which doesn’t support require or import
-
@sdetweil Could I import a json file into the config.js file instead? Would that be more straightforward?
-
@timogden no…
-
but u can write a quick bash script that can read the variables and replacements from a file and use sed (stream editor) to apply them
https://unix.stackexchange.com/questions/268640/make-multiple-edits-with-a-single-call-to-sed
use a config.model.js which is the one with the funky names to change,
cp that to config.js
loop thru the var list to make the command line, then run itand exit
then launch mm -
@sdetweil okay, thanks a lot for the reference material. I’ll work on that and post my solution when I finish. Thanks!
-
@timogden u can look at some of my scripts which get a list from a command then loop
see… restore which reads a file of module urls
-
you could use
envsubst < config/config.js.template > config/config.js
.The
config.js.template
is the config for both which contains variables for the different values. So you could write a script which sets the variables for user1 and then runenvsubst
for config1 and the same for user2/config2 afterwards. -
@karsten13 same as I suggested different tool
but envsubst needs it’s values in the environment variables… so another hidden thing (to me)
-
only wanted to post this variant …
As background: This is a feature of my docker container where you can use a
config.js.template
and the variables are defined in thedocker-compose.yml
which starts the container and before starting mm I runenvsubst
to make the realconfig.js
. -
@timogden I’ve created a module to extract the config so you don’t need to maintain your own whole MM fork: https://forum.magicmirror.builders/topic/16224/mmm-personalconfig-persist-personal-config-to-github/1
A way to achieve what you want could be to create your own copy of personal config with your mirror config. Then make a clone of if for your friend where you do the specific changes. Changes to your repo then can be pulled to the other one via Pull requests.
In combination with MMM-UpdateNotification with can pull updates automatically, your friend won’t need to do anything.