-
Notifications
You must be signed in to change notification settings - Fork 8
/
regenerate.js
executable file
·25 lines (17 loc) · 1014 Bytes
/
regenerate.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env node
import { load, dump } from "js-yaml"
import { readFileSync, writeFileSync } from "fs"
function regenerate(script_path, webhook_path, new_webhook_path) {
const script_blob = readFileSync(script_path, { encoding: "utf-8" })
const webhook_blob = readFileSync(webhook_path, { encoding: "utf-8" })
const webhook = webhook_path.endsWith(".json") ? JSON.parse(webhook_blob) : load(webhook_blob)
webhook.zabbix_export.media_types[0].script = script_blob
const webhook_result = new_webhook_path.endsWith(".json")
? JSON.stringify(webhook, null, 2)
: dump(webhook, { lineWidth: -1, quotingType: '"' })
writeFileSync(new_webhook_path, webhook_result)
}
regenerate("5.0/matrix.js", "5.0/media_matrix.yml", "5.0/media_matrix.yml")
regenerate("5.0/matrix.js", "5.0/media_matrix.yml", "5.0/media_matrix.json")
regenerate("latest/matrix.js", "latest/media_matrix.yml", "latest/media_matrix.yml")
regenerate("latest/matrix.js", "latest/media_matrix.yml", "latest/media_matrix.json")