I manage a few different projects using the very nice git/projects feature. However, I often always add custom visualizations, so I am wondering, if it is possible to define the httpStatic parameter in the settings.js dynamically?
I think of something like the following in my settings.js:
However, I cannot dig out any variable which provides the current projectpath for the selected git/project (at least not at the time this file is loaded).
The main idea is to keep the project specific static files alongside the other project files and store them in the git repo, too. This would allow:
easy switching between different projects (and their visualization/static files) without always additionally changing the settings.js
keeping additional files under version control and in sync with the actual project/flows
I've already looked at the other, similar questions (and some answers), but could not find a simple solution.
I think that is always <userDir>/projects/ though not sure if that helps since there are 2 ways to set the userDir (3 if you count letting node-red do it itself) and I don't think you can retrieve it in settings.js unless you are setting it via an environment variable or not setting it at all.
If not setting the userDir, it will always be in <userHome>/.node-red/ and you can generally get userHome from an OS environment variable (it potentially has different names on different OS's though).
Interesting question though and one that I'd be keen to see some innovative answers to.
Ah, of course, the default userDir is found with path.join(os.homedir(), '.node-red'), I even have that in my settings.js commented out
If you were using uibuilder and wanted to have project-specific front-end code, you could do:
Oops, I must have been tired last night to miss that!
If you are running node-red via systemd, you can have a file containing environment variables to be used. So you could, in theory create a flow that you put in the library and add to each new project that sets an env variable in that file and restarts node-red, that would give you access to it.