extract config to external files
Some checks failed
Check indentation / build (push) Has been cancelled
Continuous testing / build (push) Has been cancelled
Some checks failed
Check indentation / build (push) Has been cancelled
Continuous testing / build (push) Has been cancelled
This commit is contained in:
11
lib/config.mk
Normal file
11
lib/config.mk
Normal file
@@ -0,0 +1,11 @@
|
||||
JQ_INTO_TOML := '.prod|to_entries.[]|if (.value | type == "object") then "\n[" + .key + "]\n" + (.value|to_entries.[] | if (.value | type == "string") then .key + " = \"" + (.value|tostring) + "\"" else .key + " = " + (.value|tostring) end) + "\n" else if (.value | type == "string") then .key + " = \"" + (.value|tostring) + "\"" else .key + " = " + (.value|tostring) end end'
|
||||
|
||||
define to_toml
|
||||
jq -r '.$(1)|to_entries.[]|if (.value | type == "object") then "\n[" + .key + "]\n" + (.value|to_entries.[] | if (.value | type == "string") then .key + " = \"" + (.value|tostring) + "\"" else .key + " = " + (.value|tostring) end) + "\n" else if (.value | type == "string") then .key + " = \"" + (.value|tostring) + "\"" else .key + " = " + (.value|tostring) end end' $(2) > $(3)
|
||||
endef
|
||||
|
||||
dst/dev_config.toml: config.json dst
|
||||
$(call to_toml,dev,$<,$@)
|
||||
|
||||
dst/prod_config.toml: config.json dst
|
||||
$(call to_toml,prod,$<,$@)
|
Reference in New Issue
Block a user