mirror of
https://github.com/Instadapp/trustwallet-assets.git
synced 2024-07-29 22:37:31 +00:00
24 lines
762 B
TypeScript
24 lines
762 B
TypeScript
|
import {
|
||
|
readFileSync,
|
||
|
writeFileSync
|
||
|
} from "./filesystem";
|
||
|
import { sortElements } from "./types";
|
||
|
|
||
|
export function formatJsonFile(filename: string, silent: boolean = false) {
|
||
|
const jsonContent = JSON.parse(readFileSync(filename));
|
||
|
writeFileSync(filename, JSON.stringify(jsonContent, null, 4));
|
||
|
if (!silent) {
|
||
|
console.log(`Formatted json file ${filename}`);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export function formatSortJsonFile(filename: string) {
|
||
|
const jsonContent = JSON.parse(readFileSync(filename));
|
||
|
writeFileSync(filename, JSON.stringify(sortElements(jsonContent), null, 4));
|
||
|
console.log(`Formatted json file ${filename}`);
|
||
|
}
|
||
|
|
||
|
export function writeJsonFile(path: string, data: any) {
|
||
|
writeFileSync(path, JSON.stringify(data, null, 4));
|
||
|
}
|