|
1 | | -// The module 'vscode' contains the VS Code extensibility API |
2 | | -// Import the module and reference it with the alias vscode in your code below |
3 | 1 | import * as vscode from 'vscode'; |
4 | | -import * as cp from 'child_process'; |
| 2 | +import { TaskExtension } from './task'; |
5 | 3 |
|
6 | | -var outputChannel: vscode.OutputChannel; |
7 | | -var taskList: TaskList; |
8 | | - |
9 | | -// This method is called when your extension is activated |
10 | | -// Your extension is activated the very first time the command is executed |
11 | 4 | export function activate(context: vscode.ExtensionContext) { |
12 | 5 |
|
13 | | - // Create an output channel for the task output |
14 | | - outputChannel = vscode.window.createOutputChannel('task'); |
15 | | - |
16 | | - // Register commands |
17 | | - let disposable = vscode.commands.registerCommand('vscode-task.runTask', runTask); |
18 | | - |
19 | | - // Initialise the task list |
20 | | - refreshTaskList(); |
21 | | - |
22 | | - context.subscriptions.push(disposable); |
23 | | -} |
24 | | - |
25 | | -// This method is called when your extension is deactivated |
26 | | -export function deactivate() { } |
27 | | - |
28 | | -function runTask() { |
29 | | - refreshTaskList(); |
| 6 | + // Create a new instance of Tagger |
| 7 | + let taskExtension: TaskExtension = new TaskExtension(); |
30 | 8 |
|
31 | | - // Show a quick pick with all the tasks |
32 | | - vscode.window.showQuickPick(taskList.tasks.map(t => t.name)).then((taskName) => { |
| 9 | + // Registration |
| 10 | + taskExtension.registerCommands(context); |
33 | 11 |
|
34 | | - // If the user selected a task, run it |
35 | | - if (taskName) { |
36 | | - cp.exec(`task ${taskName}`, (err: cp.ExecException | null, stdout: string, stderr: string) => { |
37 | | - if (err) { |
38 | | - console.log('error: ' + err); |
39 | | - return; |
40 | | - } |
41 | | - outputChannel.append(stderr); |
42 | | - outputChannel.append(stdout); |
43 | | - outputChannel.show(); |
44 | | - }); |
45 | | - } |
| 12 | + // Refresh the tasks list |
| 13 | + taskExtension.update().catch((err: string) => { |
| 14 | + console.error(err); |
46 | 15 | }); |
47 | 16 | } |
48 | 17 |
|
49 | | -async function refreshTaskList() { |
50 | | - return await new Promise((resolve, reject) => { |
51 | | - // Get a list of all tasks |
52 | | - cp.exec('task --list-all --json', (err: cp.ExecException | null, stdout: string, stderr: string) => { |
53 | | - if (err) { |
54 | | - console.log('error: ' + err); |
55 | | - return; |
56 | | - } |
57 | | - // Parse the JSON output |
58 | | - taskList = JSON.parse(stdout); |
59 | | - resolve(stdout); |
60 | | - }); |
61 | | - }); |
62 | | -} |
63 | | - |
64 | | -interface Task { |
65 | | - name: string; |
66 | | - desc: string; |
67 | | - summary: string; |
68 | | - up_to_date: boolean; |
69 | | -} |
70 | | - |
71 | | -interface TaskList { |
72 | | - tasks: Task[]; |
73 | | -} |
| 18 | +export function deactivate() { } |
0 commit comments