mapcomplete/scripts/lint.ts

24 lines
896 B
TypeScript
Raw Normal View History

2021-09-26 18:21:29 +02:00
import ScriptUtils from "./ScriptUtils";
import {writeFileSync} from "fs";
2021-09-26 19:56:40 +02:00
import {LayerConfigJson} from "../Models/ThemeConfig/Json/LayerConfigJson";
import LineRenderingConfigJson from "../Models/ThemeConfig/Json/LineRenderingConfigJson";
import LegacyJsonConvert from "../Models/ThemeConfig/LegacyJsonConvert";
2021-09-26 18:21:29 +02:00
/*
* This script reads all theme and layer files and reformats them inplace
* Use with caution, make a commit beforehand!
2021-09-26 19:56:40 +02:00
*/
const layerFiles = ScriptUtils.getLayerFiles();
for (const layerFile of layerFiles) {
LegacyJsonConvert. fixLayerConfig(layerFile.parsed)
2021-09-26 18:21:29 +02:00
writeFileSync(layerFile.path, JSON.stringify(layerFile.parsed, null, " "))
2021-09-26 19:56:40 +02:00
}
2021-09-26 19:59:51 +02:00
2021-09-26 19:56:40 +02:00
const themeFiles = ScriptUtils.getThemeFiles()
for (const themeFile of themeFiles) {
LegacyJsonConvert.fixThemeConfig(themeFile.parsed)
2021-09-26 19:59:51 +02:00
writeFileSync(themeFile.path, JSON.stringify(themeFile.parsed, null, " "))
2021-09-26 19:58:11 +02:00
}