Skip to content
This repository was archived by the owner on Jan 10, 2019. It is now read-only.

Commit 65fda0d

Browse files
committed
added support for vs-rest-api
1 parent ffff4c8 commit 65fda0d

File tree

5 files changed

+58
-3
lines changed

5 files changed

+58
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log (vs-script-commands)
22

3+
## 1.12.0 (April 10th, 2017; REST API)
4+
5+
* added `startApi()` and `stopApi()` methods to [ScriptCommandExecutorArguments](https://mkloubert.github.io/vs-script-commands/interfaces/_contracts_.scriptcommandexecutorarguments.html) interface, which make use of commands provided by extensions like [vs-rest-api](https://github.com/mkloubert/vs-rest-api)
6+
37
## 1.11.0 (April 10th, 2017; cron jobs)
48

59
* added `getCronJobs()`, `restartCronJobs()`, `startCronJobs()` and `stopCronJobs()` methods to [ScriptCommandExecutorArguments](https://mkloubert.github.io/vs-script-commands/interfaces/_contracts_.scriptcommandexecutorarguments.html) interface, which make use of commands provided by extensions like [vs-cron](https://github.com/mkloubert/vs-cron)

img/screenshot1.png

-4.43 KB
Loading

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vs-script-commands",
33
"displayName": "Script Commands",
44
"description": "Adds additional commands to Visual Studio Code that uses scripts (JavaScript) for execution.",
5-
"version": "1.11.0",
5+
"version": "1.12.0",
66
"publisher": "mkloubert",
77
"engines": {
88
"vscode": "^1.5.0"

src/contracts.ts

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,14 @@ export type ScriptCommandArgumentFactory = (sc: ScriptCommand) => any[];
304304
*
305305
* @param {ScriptCommandExecutorArguments} args Arguments for the execution.
306306
*
307-
* @return {Promise<number> | void | number} The result (with the exit code).
307+
* @return {Promise<number>|void|number} The result (with the exit code).
308308
*/
309-
export type ScriptCommandExecutor = (args: ScriptCommandExecutorArguments) => Promise<number> | void | number;
309+
export type ScriptCommandExecutor = (args: ScriptCommandExecutorArguments) => ScriptCommandExecutorResult;
310+
311+
/**
312+
* Possible results of a script executor.
313+
*/
314+
export type ScriptCommandExecutorResult = Promise<number> | void | number;
310315

311316
/**
312317
* Arguments for a script executor.
@@ -422,6 +427,15 @@ export interface ScriptCommandExecutorArguments {
422427
* @return {Promise<any>} The promise.
423428
*/
424429
readonly restartCronJobs: (jobs: CronJobNames) => Promise<any>;
430+
/**
431+
* Starts REST API host.
432+
*
433+
* This requires 'extension.restApi.startHost' command as available in extensions like 'vs-rest-api'
434+
* s. https://github.com/mkloubert/vs-rest-api
435+
*
436+
* @return {Promise<any>} The promise.
437+
*/
438+
readonly startApi: () => Promise<any>;
425439
/**
426440
* Starts cron jobs.
427441
*
@@ -433,6 +447,15 @@ export interface ScriptCommandExecutorArguments {
433447
* @return {Promise<any>} The promise.
434448
*/
435449
readonly startCronJobs: (jobs: CronJobNames) => Promise<any>;
450+
/**
451+
* Stops REST API host.
452+
*
453+
* This requires 'extension.restApi.stopHost' command as available in extensions like 'vs-rest-api'
454+
* s. https://github.com/mkloubert/vs-rest-api
455+
*
456+
* @return {Promise<any>} The promise.
457+
*/
458+
readonly stopApi: () => Promise<any>;
436459
/**
437460
* Stops cron jobs.
438461
*

src/controller.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,20 @@ export class ScriptCommandController extends Events.EventEmitter implements vsco
772772
}
773773
});
774774
},
775+
startApi: () => {
776+
return new Promise<any>((resolve, reject) => {
777+
try {
778+
vscode.commands.executeCommand('extension.restApi.startHost').then((result) => {
779+
resolve(result);
780+
}, (err) => {
781+
reject(err);
782+
});
783+
}
784+
catch (e) {
785+
reject(e);
786+
}
787+
});
788+
},
775789
startCronJobs: (jobs) => {
776790
return new Promise<any>((resolve, reject) => {
777791
try {
@@ -786,6 +800,20 @@ export class ScriptCommandController extends Events.EventEmitter implements vsco
786800
}
787801
});
788802
},
803+
stopApi: () => {
804+
return new Promise<any>((resolve, reject) => {
805+
try {
806+
vscode.commands.executeCommand('extension.restApi.stopHost').then((result) => {
807+
resolve(result);
808+
}, (err) => {
809+
reject(err);
810+
});
811+
}
812+
catch (e) {
813+
reject(e);
814+
}
815+
});
816+
},
789817
stopCronJobs: (jobs) => {
790818
return new Promise<any>((resolve, reject) => {
791819
try {

0 commit comments

Comments
 (0)