Reputation: 730
I'm trying to develop an extension for VS Code, but I have an issue regarding the commands.
I'm starting to list the tasks of the current project but I have no idea on how achieve that.
I have started this piece of code but I don't know if it is relevant or not :
let test = vscode.commands.executeCommand('task');
Thanks in advance for the help. Kind regards.
Upvotes: 1
Views: 99
Reputation: 9222
Without more information about what you want to do, I can only guess.
You wrote:
I'm starting to list the tasks of the current project
I assume you mean that you want to list the tasks that are written in "tasks.json".
Unfortunately, the API does not expose this.
As a workaround you can try to read the file yourself by looking at the workspace root for .vscode/tasks.json
, reading the file, and trying to parse it yourself.
Something like:
import * as vscode from 'vscode';
import * as fs from 'fs';
import * as path from 'path';
export function activate(context: vscode.ExtensionContext) {
const tasksFile = path.join(vscode.workspace.rootPath, 'tasks.json');
const buffer = fs.readFileSync(tasksFile);
const tasks = buffer.toJSON().data;
console.dir('tasks', tasks);
}
Upvotes: 1