fix: remove ESM export from lib.js for QML compatibility
QML's JS engine does not support ES module export/import syntax. Replace bare export with a CommonJS guard that only runs under Node.js, so the plugin loads in QML while tests still work.
This commit is contained in:
parent
0c2376b3bb
commit
c9d1baf7c4
2 changed files with 6 additions and 2 deletions
|
|
@ -15,4 +15,7 @@ function makeExitNodeCommand(hostname) {
|
||||||
return ["tailscale", "set", "--exit-node=" + hostname]
|
return ["tailscale", "set", "--exit-node=" + hostname]
|
||||||
}
|
}
|
||||||
|
|
||||||
export { parsePeers, makeExitNodeCommand }
|
// CommonJS export for Node.js tests (ignored by QML)
|
||||||
|
if (typeof module !== "undefined" && module.exports) {
|
||||||
|
module.exports = { parsePeers, makeExitNodeCommand }
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { test } from "node:test"
|
import { test } from "node:test"
|
||||||
import assert from "node:assert"
|
import assert from "node:assert"
|
||||||
import { parsePeers, makeExitNodeCommand } from "../tailscalectl/lib.js"
|
import lib from "../tailscalectl/lib.js"
|
||||||
|
const { parsePeers, makeExitNodeCommand } = lib
|
||||||
|
|
||||||
test("parsePeers extracts exitNode from ExitNodeOption", () => {
|
test("parsePeers extracts exitNode from ExitNodeOption", () => {
|
||||||
const peerMap = {
|
const peerMap = {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue