Skip to content

Commit 31176de

Browse files
committed
Clean up docs
1 parent 531c350 commit 31176de

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ POST /execute-command HTTP/1.1
1414
{
1515
"commandId": "some-command-id",
1616
"args": [
17-
"default"
17+
"some-argument"
1818
]
1919
}
2020
```
2121

22+
Upon receiving the above, this extension would run the command `some-command-id` with argument `"some-argument"`.
23+
2224
## Release Notes

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"type": "git",
99
"url": "https://github.com/pokey/command-server"
1010
},
11-
"version": "0.1.1",
11+
"version": "0.1.2",
1212
"engines": {
1313
"vscode": "^1.53.0"
1414
},

src/extension.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,14 @@ import { AddressInfo } from "net";
66
import { writeFileSync } from "fs";
77
import { tmpdir } from "os";
88
import { join } from "path";
9+
import { getRequestJSON } from "./getRequestJSON";
910

1011
interface Command {
1112
commandId: string;
1213
args: any[];
1314
expectResponse: boolean;
1415
}
1516

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-
2617
export function activate(context: vscode.ExtensionContext) {
2718
var port: number | null = null;
2819

@@ -33,7 +24,7 @@ export function activate(context: vscode.ExtensionContext) {
3324
return;
3425
}
3526

36-
const commandInfo: Command = await getBody(req);
27+
const commandInfo: Command = await getRequestJSON(req);
3728

3829
vscode.commands.executeCommand(commandInfo.commandId, ...commandInfo.args);
3930

src/getRequestJSON.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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+
}

0 commit comments

Comments
 (0)