Add linkup command to improve link functionality

This commit is contained in:
Teffen Ellis
2021-09-15 15:17:39 -04:00
parent 6eda7ae81f
commit 2504f6fce4
6 changed files with 54 additions and 5 deletions

22
src/node/link.ts Normal file
View File

@@ -0,0 +1,22 @@
import { logger } from "@coder/logger"
import { spawn } from "child_process"
import path from "path"
export function startLink(port: number): Promise<void> {
logger.debug(`running link targetting ${port}`)
const agent = spawn(path.resolve(__dirname, "../../lib/linkup"), ["--devurl", `code:${port}:code-server`], {
shell: false,
})
return new Promise((res, rej) => {
agent.on("error", rej)
agent.on("close", (code) => {
if (code !== 0) {
return rej({
message: `Link exited with ${code}`,
})
}
res()
})
})
}