mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-06-20 20:21:45 +00:00
73d8ae8956
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Nerivec <62446222+Nerivec@users.noreply.github.com>
23 lines
666 B
JavaScript
23 lines
666 B
JavaScript
const assert = require("node:assert");
|
|
const vm = require("node:vm");
|
|
const fs = require("node:fs");
|
|
const path = require("node:path");
|
|
const filename = process.argv[2];
|
|
const moduleCode = fs.readFileSync(filename);
|
|
const moduleFakePath = path.join(__dirname, "externally-loaded.js");
|
|
const sandbox = {
|
|
require: require,
|
|
module: {},
|
|
console,
|
|
setTimeout,
|
|
clearTimeout,
|
|
setInterval,
|
|
clearInterval,
|
|
setImmediate,
|
|
clearImmediate,
|
|
};
|
|
vm.runInNewContext(moduleCode, sandbox, moduleFakePath);
|
|
const converter = sandbox.module.exports;
|
|
assert(!converter.toZigbee?.includes(undefined));
|
|
assert(!converter.fromZigbee?.includes(undefined));
|