zwave-js 11.14.0 → 11.14.1

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.
Files changed (2) hide show
  1. package/bin/mock-server.js +10 -1
  2. package/package.json +1 -1
@@ -3,6 +3,10 @@ const { MockServer } = require("../build/mockServer");
3
3
  const { readFileSync, statSync, readdirSync } = require("fs");
4
4
  const path = require("path");
5
5
 
6
+ // Allow putting .js mock configs outside the repo
7
+ const { createRequire } = require("module");
8
+ const childRequire = createRequire(module.filename);
9
+
6
10
  const args = process.argv.slice(2);
7
11
 
8
12
  /** @returns {never} */
@@ -78,7 +82,12 @@ Each node ID may only be used once in mock configs. Node ID ${nodeConfig.id} is
78
82
  */
79
83
  function getConfig(filename) {
80
84
  if (filename.endsWith(".js")) {
81
- return require(filename).default;
85
+ // The export can either be a static config object or a function that accepts a require
86
+ let config = require(filename).default;
87
+ if (typeof config === "function") {
88
+ config = config({ require: childRequire });
89
+ }
90
+ return config;
82
91
  } else if (filename.endsWith(".json")) {
83
92
  // TODO: JSON5 support
84
93
  return JSON.parse(readFileSync(filename, "utf8"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zwave-js",
3
- "version": "11.14.0",
3
+ "version": "11.14.1",
4
4
  "description": "Z-Wave driver written entirely in JavaScript/TypeScript",
5
5
  "keywords": [],
6
6
  "main": "build/index.js",