File tree Expand file tree Collapse file tree 4 files changed +17
-13
lines changed Expand file tree Collapse file tree 4 files changed +17
-13
lines changed Original file line number Diff line number Diff line change @@ -14,9 +14,11 @@ POST /execute-command HTTP/1.1
14
14
{
15
15
"commandId": "some-command-id",
16
16
"args": [
17
- "default "
17
+ "some-argument "
18
18
]
19
19
}
20
20
```
21
21
22
+ Upon receiving the above, this extension would run the command ` some-command-id ` with argument ` "some-argument" ` .
23
+
22
24
## Release Notes
Original file line number Diff line number Diff line change 8
8
"type" : " git" ,
9
9
"url" : " https://github.com/pokey/command-server"
10
10
},
11
- "version" : " 0.1.1 " ,
11
+ "version" : " 0.1.2 " ,
12
12
"engines" : {
13
13
"vscode" : " ^1.53.0"
14
14
},
Original file line number Diff line number Diff line change @@ -6,23 +6,14 @@ import { AddressInfo } from "net";
6
6
import { writeFileSync } from "fs" ;
7
7
import { tmpdir } from "os" ;
8
8
import { join } from "path" ;
9
+ import { getRequestJSON } from "./getRequestJSON" ;
9
10
10
11
interface Command {
11
12
commandId : string ;
12
13
args : any [ ] ;
13
14
expectResponse : boolean ;
14
15
}
15
16
16
- function getBody ( req : http . IncomingMessage ) {
17
- return new Promise < any > ( ( resolve , reject ) => {
18
- var body = "" ;
19
- req . on ( "data" , function ( chunk ) {
20
- body += chunk ;
21
- } ) ;
22
- req . on ( "end" , ( ) => resolve ( JSON . parse ( body ) ) ) ;
23
- } ) ;
24
- }
25
-
26
17
export function activate ( context : vscode . ExtensionContext ) {
27
18
var port : number | null = null ;
28
19
@@ -33,7 +24,7 @@ export function activate(context: vscode.ExtensionContext) {
33
24
return ;
34
25
}
35
26
36
- const commandInfo : Command = await getBody ( req ) ;
27
+ const commandInfo : Command = await getRequestJSON ( req ) ;
37
28
38
29
vscode . commands . executeCommand ( commandInfo . commandId , ...commandInfo . args ) ;
39
30
Original file line number Diff line number Diff line change
1
+ import * as http from "http" ;
2
+
3
+ export function getRequestJSON ( req : http . IncomingMessage ) {
4
+ return new Promise < any > ( ( resolve , reject ) => {
5
+ var body = "" ;
6
+ req . on ( "data" , function ( chunk ) {
7
+ body += chunk ;
8
+ } ) ;
9
+ req . on ( "end" , ( ) => resolve ( JSON . parse ( body ) ) ) ;
10
+ } ) ;
11
+ }
You can’t perform that action at this time.
0 commit comments