Skip to content

Commit

Permalink
add comment describing file and error log explaining the format
Browse files Browse the repository at this point in the history
  • Loading branch information
blaine-arcjet committed Sep 3, 2024
1 parent c6366c9 commit d4783c8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions format.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
/**
* This file is used for checking and updating the format of the JSON file.
*
* You can check the format via `node format.js --check` and regenerate the
* file with the correct formatting using `node format.js --generate`.
*
* The formatting logic uses `JSON.stringify` with 2 spaces, which will keep
* separating commas on the same line as any closing character. This technique
* was chosen for simplicty and to align with common default JSON formatters,
* such as VSCode.
*/

const fs = require("fs");
const path = require("path");

Expand All @@ -15,6 +27,7 @@ if (process.argv[2] === "--generate") {
if (process.argv[2] === "--check") {
if (updated !== original) {
console.error("JSON file format is wrong. Run `node format.js --generate` to update.");
console.error("Format must be 2 spaces, with newlines for objects and arrays, and separating commas on the line with the previous closing character.");
process.exit(1);
}
}
Expand Down

0 comments on commit d4783c8

Please sign in to comment.