Add view output action
Signed-off-by: Sanjula Ganepola <sanjulagane@gmail.com>
This commit is contained in:
22
package.json
22
package.json
@@ -202,6 +202,13 @@
|
|||||||
"title": "Refresh",
|
"title": "Refresh",
|
||||||
"icon": "$(refresh)"
|
"icon": "$(refresh)"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"category": "GitHub Local Actions",
|
||||||
|
"command": "githubLocalActions.viewOutput",
|
||||||
|
"title": "View Output",
|
||||||
|
"enablement": "viewItem =~ /^githubLocalActions.history_(Success|Failed|Cancelled).*/",
|
||||||
|
"icon": "$(book)"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"category": "GitHub Local Actions",
|
"category": "GitHub Local Actions",
|
||||||
"command": "githubLocalActions.restart",
|
"command": "githubLocalActions.restart",
|
||||||
@@ -280,6 +287,10 @@
|
|||||||
"command": "githubLocalActions.refreshHistory",
|
"command": "githubLocalActions.refreshHistory",
|
||||||
"when": "never"
|
"when": "never"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"command": "githubLocalActions.viewOutput",
|
||||||
|
"when": "never"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"command": "githubLocalActions.restart",
|
"command": "githubLocalActions.restart",
|
||||||
"when": "never"
|
"when": "never"
|
||||||
@@ -366,19 +377,24 @@
|
|||||||
"group": "inline@0"
|
"group": "inline@0"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "githubLocalActions.restart",
|
"command": "githubLocalActions.viewOutput",
|
||||||
"when": "view == history && viewItem =~ /^githubLocalActions.history.*/",
|
"when": "view == history && viewItem =~ /^githubLocalActions.history.*/",
|
||||||
"group": "inline@0"
|
"group": "inline@0"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "githubLocalActions.stop",
|
"command": "githubLocalActions.restart",
|
||||||
"when": "view == history && viewItem =~ /^githubLocalActions.history.*/",
|
"when": "view == history && viewItem =~ /^githubLocalActions.history.*/",
|
||||||
"group": "inline@1"
|
"group": "inline@1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "githubLocalActions.remove",
|
"command": "githubLocalActions.stop",
|
||||||
"when": "view == history && viewItem =~ /^githubLocalActions.history.*/",
|
"when": "view == history && viewItem =~ /^githubLocalActions.history.*/",
|
||||||
"group": "inline@2"
|
"group": "inline@2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "githubLocalActions.remove",
|
||||||
|
"when": "view == history && viewItem =~ /^githubLocalActions.history.*/",
|
||||||
|
"group": "inline@3"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
12
src/act.ts
12
src/act.ts
@@ -240,6 +240,14 @@ export class Act {
|
|||||||
const writeEmitter = new EventEmitter<string>();
|
const writeEmitter = new EventEmitter<string>();
|
||||||
const closeEmitter = new EventEmitter<number>();
|
const closeEmitter = new EventEmitter<number>();
|
||||||
|
|
||||||
|
writeEmitter.event(data => {
|
||||||
|
if (!this.workspaceHistory[commandArgs.workspaceFolder.uri.fsPath][historyIndex].output) {
|
||||||
|
this.workspaceHistory[commandArgs.workspaceFolder.uri.fsPath][historyIndex].output = data;
|
||||||
|
} else {
|
||||||
|
this.workspaceHistory[commandArgs.workspaceFolder.uri.fsPath][historyIndex].output += data;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const exec = child_process.spawn(command, { cwd: commandArgs.workspaceFolder.uri.fsPath, shell: env.shell });
|
const exec = child_process.spawn(command, { cwd: commandArgs.workspaceFolder.uri.fsPath, shell: env.shell });
|
||||||
const handleIO = (data: any) => {
|
const handleIO = (data: any) => {
|
||||||
const lines: string[] = data.toString().split('\n').filter((line: string) => line != '');
|
const lines: string[] = data.toString().split('\n').filter((line: string) => line != '');
|
||||||
@@ -354,6 +362,10 @@ export class Act {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async viewOutput(history: History) {
|
||||||
|
await workspace.openTextDocument({ content: history.output });
|
||||||
|
}
|
||||||
|
|
||||||
async stop(history: History) {
|
async stop(history: History) {
|
||||||
history.taskExecution?.terminate();
|
history.taskExecution?.terminate();
|
||||||
historyTreeDataProvider.refresh();
|
historyTreeDataProvider.refresh();
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ export default class HistoryTreeDataProvider implements TreeDataProvider<GithubL
|
|||||||
commands.registerCommand('githubLocalActions.refreshHistory', async () => {
|
commands.registerCommand('githubLocalActions.refreshHistory', async () => {
|
||||||
this.refresh();
|
this.refresh();
|
||||||
}),
|
}),
|
||||||
|
commands.registerCommand('githubLocalActions.viewOutput', async (historyTreeItem: HistoryTreeItem) => {
|
||||||
|
await act.viewOutput(historyTreeItem.history);
|
||||||
|
}),
|
||||||
commands.registerCommand('githubLocalActions.restart', async (historyTreeItem: HistoryTreeItem) => {
|
commands.registerCommand('githubLocalActions.restart', async (historyTreeItem: HistoryTreeItem) => {
|
||||||
await act.runCommand(historyTreeItem.history.commandArgs);
|
await act.runCommand(historyTreeItem.history.commandArgs);
|
||||||
}),
|
}),
|
||||||
|
|||||||
Reference in New Issue
Block a user