feat(modules.constructFiles): auto-sanitize .key value to always be valid#399
Conversation
baa1d45 to
5d08642
Compare
|
Will we ever have to look at the sanitized keys? If it's important that the sanitize function results in something human-readable and there is the possibility for collisions, I would at the very least want a safety hatch where we could override things in case of collisions. |
|
They are in But, you don't actually need to use those values, you would modify them via the You just need to not overwrite them on accident.
When a collision occurs, it adds And if you set the value to a valid shell variable name, it will not modify it, unless it collides with something |
5d08642 to
4d45b68
Compare
If no collisions can occur, then thumbs up by me :-) |
|
|
||
| Examples: | ||
| ``` | ||
| sanitizeEnvVarName "FOO-BAR" => "FOOBAR" |
There was a problem hiding this comment.
Maybe we can keep "_" as the only separator and make it become FOO_BAR (same for FOO.BAR, FOO+BAR etc)
This would certainly avoid a whole class of collisions where your workaround with _0, _1,... would be needed otherwise.
There was a problem hiding this comment.
This would certainly avoid a whole class of collisions where your workaround with _0, _1,... would be needed otherwise.
It would not, although there would be fewer instances
I can do this though, just substitute all invalid characters with _, that is fine with me.
There was a problem hiding this comment.
I'm nitpicking.
I was just thinking this might reduce clashes like dotdir vs dot-dir but in the end its up to you.
In the end it doesn't really matter as it is hidden away from the user anyway.
There was a problem hiding this comment.
It actually simplified the sanitizeEnvVarName function to do it that way
|
@BirdeeHub can you ping me at #378 once this is merged s.t. I can clean things up using this? |
b6c670d to
88545f3
Compare
e4244b1 to
cbc8d2c
Compare
…alid should make it easier to map multiple things to generated files
cbc8d2c to
e534a5e
Compare
|
Ill clean up the existing modules I maintain where I needed to work around this eventually, but they are fine for now. But going forward this should be nicer. @zenoli Im merging this. |
Is this a good idea? Thumbs up or thumbs down to vote I suppose?