Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { execSync } from "node:child_process"
import { readFileSync } from "node:fs"
import { homedir } from "node:os"
import { join } from "node:path"
import { LSOF_LISTEN_RE } from "./lsof.js"
import {
notify,
setStatus,
Expand All @@ -16,8 +17,6 @@ import {
type SplitDirection,
} from "./cmux.js"

export const LSOF_LISTEN_RE = /:(\d+)\s+\(LISTEN\)/

const plugin: Plugin = async ({ client, $ }) => {
const pendingPermissions = new Set<string>()
const pendingQuestions = new Set<string>()
Expand Down
1 change: 1 addition & 0 deletions src/lsof.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const LSOF_LISTEN_RE = /:(\d+)\s+\(LISTEN\)/
2 changes: 1 addition & 1 deletion test/lsof-parse.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test, expect } from "bun:test"
import { LSOF_LISTEN_RE } from "../src/index"
import { LSOF_LISTEN_RE } from "../src/lsof"

test("LSOF_LISTEN_RE captures the port from a real lsof line", () => {
const line =
Expand Down
27 changes: 27 additions & 0 deletions test/plugin-export.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { test, expect } from "bun:test"
import { existsSync } from "node:fs"
import { execFileSync } from "node:child_process"
import plugin from "../src/index"
import * as pluginModule from "../src/index"

async function loadBuiltPluginModule() {
const builtPluginPath = new URL("../dist/index.js", import.meta.url)

if (!existsSync(builtPluginPath)) {
execFileSync("bun", ["run", "build"], { stdio: "inherit" })
}

return import("../dist/index.js")
}

test("public plugin module only exposes a default function export", () => {
expect(typeof plugin).toBe("function")
expect(Object.keys(pluginModule)).toEqual(["default"])
})

test("built plugin module only exposes a default function export", async () => {
const builtPluginModule = await loadBuiltPluginModule()

expect(typeof builtPluginModule.default).toBe("function")
expect(Object.keys(builtPluginModule)).toEqual(["default"])
})