diff --git a/src/command.ts b/src/command.ts index 7cbfaa2..1c07813 100644 --- a/src/command.ts +++ b/src/command.ts @@ -6,7 +6,7 @@ export class Command { private readonly args: object | null ) {} - public execute() { + public execute(): Thenable{ if (this.args === null) { return vscode.commands.executeCommand(this.exe); } else { diff --git a/src/extension.ts b/src/extension.ts index 38f88ee..69ee1bd 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -89,7 +89,7 @@ function refreshUserCommands(context: vscode.ExtensionContext) { context.subscriptions.push( vscode.commands.registerCommand(key, async () => { - await multiCommand.execute(); + await await multiCommand.execute(); }) ); }); @@ -109,12 +109,12 @@ export function activate(context: vscode.ExtensionContext) { async (args = {}) => { try { if (args.command) { - await vscode.commands.executeCommand(args.command); + return await vscode.commands.executeCommand(args.command); } else if (args.sequence) { const multiCommand = createMultiCommand("", args); - await multiCommand.execute(); + return await await multiCommand.execute(); } else { - await pickMultiCommand(); + return await await pickMultiCommand(); } } catch (e) { vscode.window.showErrorMessage(`${e.message}`); @@ -126,7 +126,7 @@ export function activate(context: vscode.ExtensionContext) { // this method is called when your extension is deactivated export function deactivate() {} -export async function pickMultiCommand() { +export async function pickMultiCommand(): Promise | undefined> { const picks = multiCommands.map((multiCommand) => { return { label: multiCommand.label || multiCommand.id, diff --git a/src/multiCommand.ts b/src/multiCommand.ts index 5031206..21b1f39 100644 --- a/src/multiCommand.ts +++ b/src/multiCommand.ts @@ -9,11 +9,14 @@ export class MultiCommand { readonly sequence: Array ) {} - public async execute() { + public async execute(): Promise | unknown> { + let lastOutput: Thenable | undefined; for (let command of this.sequence) { - await command.execute(); + lastOutput = command.execute(); await delay(this.interval || 0); } + + return lastOutput; } }