forked from microsoft/devicescript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.ts
More file actions
27 lines (24 loc) · 778 Bytes
/
deploy.ts
File metadata and controls
27 lines (24 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { devsFactory } from "./build"
import { CmdOptions, error } from "./command"
import { readCompiled } from "./run"
export interface RunOptions {
tcp?: boolean
}
export async function deployScript(
fn: string,
options: RunOptions & CmdOptions
) {
const inst = await devsFactory()
if (options.tcp)
await inst.setupNodeTcpSocketTransport(require, "127.0.0.1", 8082)
else await inst.setupWebsocketTransport("ws://127.0.0.1:8081")
inst.devsStart()
inst.deployHandler = code => {
if (code) error(`deploy error ${code}`)
process.exit(code)
}
const prog = await readCompiled(fn)
const r = inst.devsClientDeploy(prog)
if (r) throw new Error("deploy error: " + r)
console.log(`remote-deployed ${fn}`)
}