Skip to content

Commit

Permalink
Extended with command
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianRappl committed Nov 12, 2023
1 parent 05e5735 commit 393a695
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,12 @@
"taskDefinitions": [
{
"type": "piral",
"required": [],
"required": ["command"],
"properties": {
"command": {
"type": "string",
"description": "The command to run (debug, build, validate, declaration)."
},
"flags": {
"type": "array",
"description": "Additional flags for running piral debug."
Expand All @@ -229,8 +233,12 @@
},
{
"type": "pilet",
"required": [],
"required": ["command"],
"properties": {
"command": {
"type": "string",
"description": "The command to run (debug, build, validate, pack)."
},
"flags": {
"type": "array",
"description": "Additional flags for running pilet debug."
Expand Down
18 changes: 17 additions & 1 deletion src/extension/providers/piletTaskProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@ export class PiletTaskProvider implements vscode.TaskProvider {

interface PiletTaskDefinition extends vscode.TaskDefinition {
/**
* Additional build flags
* The command to use.
*/
command: string;
/**
* Additional build flags.
*/
flags?: Array<string>;
}

function createDebugTask(workspaceFolder: vscode.WorkspaceFolder) {
const kind: PiletTaskDefinition = {
type: PiletTaskProvider.Type,
command: 'debug',
flags: [],
};
const command = ['npx', 'pilet', 'debug', ...(kind.flags || [])].join(' ');
Expand All @@ -41,13 +46,16 @@ function createDebugTask(workspaceFolder: vscode.WorkspaceFolder) {
['$piral-cli-debug'],
);
task.isBackground = true;
task.runOptions.reevaluateOnRerun = true;
task.presentationOptions.panel = vscode.TaskPanelKind.New;
task.group = vscode.TaskGroup.Build;
return task;
}

function createBuildTask(workspaceFolder: vscode.WorkspaceFolder) {
const kind: PiletTaskDefinition = {
type: PiletTaskProvider.Type,
command: 'build',
flags: [],
};
const command = ['npx', 'pilet', 'build', ...(kind.flags || [])].join(' ');
Expand All @@ -59,12 +67,15 @@ function createBuildTask(workspaceFolder: vscode.WorkspaceFolder) {
new vscode.ShellExecution(command),
);
task.group = vscode.TaskGroup.Build;
task.runOptions.reevaluateOnRerun = true;
task.presentationOptions.panel = vscode.TaskPanelKind.New;
return task;
}

function createValidateTask(workspaceFolder: vscode.WorkspaceFolder) {
const kind: PiletTaskDefinition = {
type: PiletTaskProvider.Type,
command: 'validate',
flags: [],
};
const command = ['npx', 'pilet', 'validate', ...(kind.flags || [])].join(' ');
Expand All @@ -76,12 +87,15 @@ function createValidateTask(workspaceFolder: vscode.WorkspaceFolder) {
new vscode.ShellExecution(command),
);
task.group = vscode.TaskGroup.Test;
task.runOptions.reevaluateOnRerun = true;
task.presentationOptions.panel = vscode.TaskPanelKind.New;
return task;
}

function createPackTask(workspaceFolder: vscode.WorkspaceFolder) {
const kind: PiletTaskDefinition = {
type: PiletTaskProvider.Type,
command: 'pack',
flags: [],
};
const command = ['npx', 'pilet', 'pack', ...(kind.flags || [])].join(' ');
Expand All @@ -93,6 +107,8 @@ function createPackTask(workspaceFolder: vscode.WorkspaceFolder) {
new vscode.ShellExecution(command),
);
task.group = vscode.TaskGroup.Build;
task.runOptions.reevaluateOnRerun = true;
task.presentationOptions.panel = vscode.TaskPanelKind.New;
return task;
}

Expand Down
10 changes: 9 additions & 1 deletion src/extension/providers/piralTaskProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@ export class PiralTaskProvider implements vscode.TaskProvider {

interface PiralTaskDefinition extends vscode.TaskDefinition {
/**
* Additional build flags
* The command to use.
*/
command: string;
/**
* Additional build flags.
*/
flags?: Array<string>;
}

function createDebugTask(workspaceFolder: vscode.WorkspaceFolder) {
const kind: PiralTaskDefinition = {
type: PiralTaskProvider.Type,
command: 'debug',
flags: [],
};
const command = ['npx', 'piral', 'debug', ...(kind.flags || [])].join(' ');
Expand All @@ -43,6 +48,7 @@ function createDebugTask(workspaceFolder: vscode.WorkspaceFolder) {
function createBuildTask(workspaceFolder: vscode.WorkspaceFolder) {
const kind: PiralTaskDefinition = {
type: PiralTaskProvider.Type,
command: 'build',
flags: [],
};
const command = ['npx', 'piral', 'build', ...(kind.flags || [])].join(' ');
Expand All @@ -54,6 +60,7 @@ function createBuildTask(workspaceFolder: vscode.WorkspaceFolder) {
function createValidateTask(workspaceFolder: vscode.WorkspaceFolder) {
const kind: PiralTaskDefinition = {
type: PiralTaskProvider.Type,
command: 'validate',
flags: [],
};
const command = ['npx', 'piral', 'validate', ...(kind.flags || [])].join(' ');
Expand All @@ -65,6 +72,7 @@ function createValidateTask(workspaceFolder: vscode.WorkspaceFolder) {
function createDeclarationTask(workspaceFolder: vscode.WorkspaceFolder) {
const kind: PiralTaskDefinition = {
type: PiralTaskProvider.Type,
command: 'declaration',
flags: [],
};
const command = ['npx', 'piral', 'declaration', ...(kind.flags || [])].join(' ');
Expand Down

0 comments on commit 393a695

Please sign in to comment.