Stabilize formatting

This commit is contained in:
pietervdvn 2022-03-31 02:58:31 +02:00
parent 9d2bdb9bbd
commit e29319e718

View file

@ -293,11 +293,11 @@ function sortKeys(o: object): object{
* Formats the specified file, helps to prevent merge conflicts
* */
function formatFile(path) {
let contents = JSON.parse(readFileSync(path, "utf8"))
const original = readFileSync(path, "utf8")
let contents = JSON.parse(original)
contents = sortKeys(contents)
writeFileSync(path, JSON.stringify(contents, null, " "))
const endsWithNewline = original.endsWith("\n")
writeFileSync(path, JSON.stringify(contents, null, " ") + (endsWithNewline ? "\n" : ""))
}
/**