-
Notifications
You must be signed in to change notification settings - Fork 1
/
dev.ts
87 lines (62 loc) · 1.63 KB
/
dev.ts
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import { ramdisk, Remote } from 'xshell'
import { builder, fpd_root } from './builder.ts'
await builder.build(false)
let remote: Remote
// 监听终端快捷键
// https://stackoverflow.com/a/12506613/7609214
let { stdin } = process
stdin.setRawMode(true)
stdin.resume()
stdin.setEncoding('utf-8')
// on any data into stdin
stdin.on('data', function (key: any) {
// ctrl-c ( end of text )
if (key === '\u0003')
process.exit()
// write the key to stdout all normal like
console.log(key)
switch (key) {
case 'r':
builder.run()
break
case 'x':
remote?.disconnect()
process.exit()
case 'i':
console.log(info)
break
}
})
if (ramdisk) {
remote = new Remote({
url: 'ws://localhost',
keeper: {
func: 'register',
args: ['ddb.ext'],
},
funcs: {
async recompile () {
await builder.run()
return [ ]
},
async exit () {
await builder.close()
remote.disconnect()
process.exit()
}
}
})
await remote.connect()
}
const info =
'可以使用下面的命令调试:\n' +
`code.exe --extensionDevelopmentPath=${fpd_root}out/ ${fpd_root}workspace/\n`
console.log(
'\n' +
'extension 开发服务器启动成功\n'.green +
info +
'终端快捷键:\n' +
'r: 重新编译\n' +
'i: 打印调试命令\n' +
'x: 退出开发服务器\n'
)