5etools-utils 0.11.3 → 0.12.0

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/lib/BrewTester.js CHANGED
@@ -77,23 +77,33 @@ class _BrewTesterFileLocations {
77
77
  }
78
78
  }
79
79
 
80
- class _BrewTesterFileExtensions {
81
- static _LOG_TAG = `FILE_EXTS`;
80
+ class _BrewTesterFileNames {
81
+ static _LOG_TAG = `FILE_NAME`;
82
+
83
+ static _RE_NAME_FORMAT = /^[^;]+; .+\.json$/;
82
84
 
83
85
  static run () {
84
- Um.info(this._LOG_TAG, `Testing for incorrect file extensions...`);
86
+ Um.info(this._LOG_TAG, `Testing for incorrect file names...`);
85
87
 
86
88
  const errors = [];
87
89
 
88
90
  Uf.runOnDirs((dir) => {
91
+ const filenames = fs.readdirSync(dir);
92
+
89
93
  errors.push(
90
- ...fs.readdirSync(dir)
94
+ ...filenames
91
95
  .filter(it => !it.endsWith(".json"))
92
96
  .map(it => `File did not have ".json" extension: ${it}`),
93
97
  );
98
+
99
+ errors.push(
100
+ ...filenames
101
+ .filter(it => !this._RE_NAME_FORMAT.test(it))
102
+ .map(it => `Filename did not match expected pattern "${this._RE_NAME_FORMAT.toString()}" extension: ${it}`),
103
+ );
94
104
  });
95
105
 
96
- if (!errors.length) return Um.info(this._LOG_TAG, `Files had expected extensions.`);
106
+ if (!errors.length) return Um.info(this._LOG_TAG, `Files had expected names.`);
97
107
 
98
108
  errors.forEach(it => console.error(it));
99
109
  process.exit(1);
@@ -103,7 +113,7 @@ class _BrewTesterFileExtensions {
103
113
  class BrewTester {
104
114
  static async pTestJson (args, opts) { return _BrewTesterJson.pRun(args, opts); }
105
115
  static testFileLocations () { return _BrewTesterFileLocations.run(); }
106
- static testFileExtensions () { return _BrewTesterFileExtensions.run(); }
116
+ static testFileNames () { return _BrewTesterFileNames.run(); }
107
117
  }
108
118
 
109
119
  export {BrewTester};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "5etools-utils",
3
- "version": "0.11.3",
3
+ "version": "0.12.0",
4
4
  "description": "Shared utilities for the 5etools ecosystem.",
5
5
  "type": "module",
6
6
  "main": "lib/Api.js",
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import {BrewTester} from "../lib/BrewTester.js";
4
-
5
- BrewTester.testFileExtensions();