diff --git a/.vscode/launch.json b/.vscode/launch.json index 00e3862ace5e0..5f7fa0933b6d9 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -34,7 +34,7 @@ "--app-project-path=${workspaceFolder}/examples/electron", "--remote-debugging-port=9222", "--no-app-auto-install", - "--plugins=local-dir:../../plugins", + "--plugins=local-dir:../../sample-plugins/sample-namespace", "--ovsx-router-config=${workspaceFolder}/examples/ovsx-router-config.json" ], "env": { diff --git a/package.json b/package.json index dbda4a4b56a5d..422f90d9e78f5 100644 --- a/package.json +++ b/package.json @@ -59,10 +59,10 @@ "yargs": "^15.3.1" }, "scripts": { - "all": "yarn -s install && yarn -s lint && yarn -s build", + "all": "yarn -s install && yarn -s build", "browser": "yarn -s --cwd examples/browser", "build": "yarn -s compile && yarn -s build:examples", - "build:examples": "yarn browser build && yarn electron build", + "build:examples": "yarn electron build", "clean": "yarn -s rebuild:clean && yarn -s lint:clean && node scripts/run-reverse-topo.js yarn -s clean", "compile": "echo Compiling TypeScript sources... && yarn -s compile:clean && yarn -s compile:tsc", "compile:clean": "ts-clean dev-packages/* packages/*", diff --git a/sample-plugins/sample-namespace/plugin-a/customTaskProvider.js b/sample-plugins/sample-namespace/plugin-a/customTaskProvider.js new file mode 100644 index 0000000000000..1256439891814 --- /dev/null +++ b/sample-plugins/sample-namespace/plugin-a/customTaskProvider.js @@ -0,0 +1,50 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CustomTaskProvider = void 0; +const vscode = require("vscode"); +class CustomTaskTerminal { + constructor() { + this.writeEmitter = new vscode.EventEmitter(); + this.onDidWrite = this.writeEmitter.event; + this.closeEmitter = new vscode.EventEmitter(); + this.onDidClose = this.closeEmitter.event; + } + open(initialDimensions) { + const output = 'somefile.abc:1:4: warning: the roof is on fire '; + this.doBuild(output); + } + close() { + this.writeEmitter.dispose(); + this.closeEmitter.fire(0); + this.closeEmitter.dispose(); + } + async doBuild(output) { + return new Promise((resolve) => { + this.writeEmitter.fire('Starting build...\r\n'); + this.writeEmitter.fire(output + '\r\n'); + this.close(); + resolve(); + }); + } +} +class CustomTaskProvider { + async provideTasks() { + return this.getTask(); + } + resolveTask(_task) { + return undefined; + } + getTask() { + const definition = { + type: CustomTaskProvider.type + }; + return [new vscode.Task(definition, vscode.TaskScope.Workspace, `my custom`, CustomTaskProvider.type, new vscode.CustomExecution(async () => { + return new CustomTaskTerminal(); + })), + new vscode.Task(definition, vscode.TaskScope.Workspace, `my shell`, CustomTaskProvider.type, new vscode.ShellExecution('echo Shell')), + new vscode.Task(definition, vscode.TaskScope.Workspace, `my process`, CustomTaskProvider.type, new vscode.ProcessExecution('echo Process'))]; + } +} +exports.CustomTaskProvider = CustomTaskProvider; +CustomTaskProvider.type = 'mytasktype'; +//# sourceMappingURL=customTaskProvider.js.map diff --git a/sample-plugins/sample-namespace/plugin-a/extension.js b/sample-plugins/sample-namespace/plugin-a/extension.js index 444471f16aff0..1f548b7ba840e 100644 --- a/sample-plugins/sample-namespace/plugin-a/extension.js +++ b/sample-plugins/sample-namespace/plugin-a/extension.js @@ -15,9 +15,19 @@ // ***************************************************************************** const vscode = require('vscode'); +const customTaskProvider_1 = require("./customTaskProvider"); + +let customTaskProvider; exports.activate = function (context) { context.subscriptions.push(vscode.commands.registerCommand('plugin-a.hello', () => { vscode.window.showInformationMessage('Hello from plugin-a!'); + customTaskProvider = vscode.tasks.registerTaskProvider(customTaskProvider_1.CustomTaskProvider.type, new customTaskProvider_1.CustomTaskProvider()); })); } + +exports.deactivate = function deactivate() { + if (customTaskProvider) { + customTaskProvider.dispose(); + } +}; diff --git a/sample-plugins/sample-namespace/plugin-a/package.json b/sample-plugins/sample-namespace/plugin-a/package.json index 9b3b6f8bea198..0d0a54808d5c5 100644 --- a/sample-plugins/sample-namespace/plugin-a/package.json +++ b/sample-plugins/sample-namespace/plugin-a/package.json @@ -27,6 +27,11 @@ "command": "plugin-a.hello", "title": "Hello from plugin-a" } + ], + "taskDefinitions": [ + { + "type": "mytasktype" + } ] } }