-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: first pass * refactor: use task provider class * refactor: follow task example * chore: update docs
- Loading branch information
Showing
5 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,10 @@ | |
|
||
## [Unreleased] | ||
|
||
### Added | ||
|
||
- Task runner support | ||
|
||
## [0.7.0] - 2025-01-02 | ||
|
||
### Added | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ Commands: | |
|
||
- Format on save | ||
- Run recipe | ||
- Task running | ||
|
||
|
||
Demo: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import * as vscode from 'vscode'; | ||
|
||
import { EXTENSION_NAME } from './const'; | ||
import { getJustPath } from './utils'; | ||
|
||
export interface TaskDefinition extends vscode.TaskDefinition { | ||
task: string; | ||
args?: string[]; | ||
} | ||
|
||
export class TaskProvider implements vscode.TaskProvider { | ||
public constructor() {} | ||
|
||
public provideTasks() { | ||
return [getDefaultRecipeTask()]; | ||
} | ||
|
||
public resolveTask(_task: vscode.Task) { | ||
if (_task.definition.type !== EXTENSION_NAME) return undefined; | ||
|
||
const definition = _task.definition as TaskDefinition; | ||
|
||
return new vscode.Task( | ||
definition, | ||
_task.scope ?? vscode.TaskScope.Workspace, | ||
definition.label ?? 'Run recipe', | ||
definition.type, | ||
new vscode.ShellExecution(definition.task, definition.args ?? []), | ||
); | ||
} | ||
} | ||
|
||
export const getDefaultRecipeTask = () => { | ||
const runDefaultRecipeTask = new vscode.Task( | ||
{ type: EXTENSION_NAME, task: 'just' }, | ||
vscode.TaskScope.Workspace, | ||
'Run default recipe', | ||
EXTENSION_NAME, | ||
new vscode.ShellExecution(getJustPath()), | ||
); | ||
runDefaultRecipeTask.presentationOptions = { | ||
showReuseMessage: false, | ||
close: false, | ||
}; | ||
|
||
return runDefaultRecipeTask; | ||
}; |