crawler-user-agents 1.0.145 → 1.0.147

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/format.js ADDED
@@ -0,0 +1,34 @@
1
+ /**
2
+ * This file is used for checking and updating the format of the JSON file.
3
+ *
4
+ * You can check the format via `node format.js --check` and regenerate the
5
+ * file with the correct formatting using `node format.js --generate`.
6
+ *
7
+ * The formatting logic uses `JSON.stringify` with 2 spaces, which will keep
8
+ * separating commas on the same line as any closing character. This technique
9
+ * was chosen for simplicty and to align with common default JSON formatters,
10
+ * such as VSCode.
11
+ */
12
+
13
+ const fs = require("fs");
14
+ const path = require("path");
15
+
16
+ const jsonFilePath = path.join(__dirname, "crawler-user-agents.json");
17
+
18
+ const original = fs.readFileSync(jsonFilePath, "utf-8");
19
+
20
+ const updated = JSON.stringify(JSON.parse(original), null, 2) + '\n';
21
+
22
+ if (process.argv[2] === "--generate") {
23
+ fs.writeFileSync(jsonFilePath, updated);
24
+ process.exit(0);
25
+ }
26
+
27
+ if (process.argv[2] === "--check") {
28
+ if (updated !== original) {
29
+ console.error("JSON file format is wrong. Run `node format.js --generate` to update.");
30
+ console.error("Format must be 2 spaces, with newlines for objects and arrays, and separating commas on the line with the previous closing character.");
31
+ process.exit(1);
32
+ }
33
+ }
34
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "crawler-user-agents",
3
- "version": "1.0.145",
3
+ "version": "1.0.147",
4
4
  "main": "crawler-user-agents.json",
5
5
  "typings": "./index.d.ts",
6
6
  "author": "Martin Monperrus <martin.monperrus@gnieh.org>",