Skip to content

Instantly share code, notes, and snippets.

@rcla
Created Jun 25, 2021
Embed
What would you like to do?
import { injectable, inject } from "inversify";
import { CommandContribution, CommandRegistry, MenuContribution, MenuModelRegistry, MessageService } from "@theia/core/lib/common";
import { CommonMenus } from "@theia/core/lib/browser";
import { TaskConfiguration, TaskScope } from '@theia/task/lib/common';
import { TaskService } from '@theia/task/lib/browser/task-service';
export const TestMakeCommand = {
id: 'TestMake.command',
label: "Test Make"
};
const myTask: TaskConfiguration = {
"_scope": TaskScope.Global,
"label": "Test Make",
"type": "shell",
"command": "/usr/bin/make",
"args": [
"-v"
],
"options": {
"cwd": "/home/bud-rey/Test"
}
}
@injectable()
export class TestMakeCommandContribution implements CommandContribution {
constructor(
@inject(TaskService) private readonly taskService: TaskService,
@inject(MessageService) private readonly messageService: MessageService,
) { }
registerCommands(registry: CommandRegistry): void {
registry.registerCommand(TestMakeCommand, {
execute: () => {
this.taskService.runTask(myTask);
this.messageService.info('Test Make');
}
});
}
}
@injectable()
export class TestMakeMenuContribution implements MenuContribution {
registerMenus(menus: MenuModelRegistry): void {
menus.registerMenuAction(CommonMenus.EDIT_FIND, {
commandId: TestMakeCommand.id,
label: TestMakeCommand.label
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment