Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/commands/compose/compose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ async function compose(context: IActionContext, commands: ('up' | 'down' | 'upSu
const taskCRF = new TaskCommandRunnerFactory({
taskName: client.displayName,
workspaceFolder: folder,
close: true,
});

await taskCRF.getCommandRunner()(terminalCommand);
Expand Down
12 changes: 7 additions & 5 deletions src/commands/containers/composeGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ export async function composeGroupLogs(context: IActionContext, node: ContainerG
}

export async function composeGroupStart(context: IActionContext, node: ContainerGroupTreeItem): Promise<void> {
return composeGroup(context, (client, options) => client.start(options), node);
return composeGroup(context, (client, options) => client.start(options), node, undefined, true);
}

export async function composeGroupStop(context: IActionContext, node: ContainerGroupTreeItem): Promise<void> {
return composeGroup(context, (client, options) => client.stop(options), node);
return composeGroup(context, (client, options) => client.stop(options), node, undefined, true);
}

export async function composeGroupRestart(context: IActionContext, node: ContainerGroupTreeItem): Promise<void> {
return composeGroup(context, (client, options) => client.restart(options), node);
return composeGroup(context, (client, options) => client.restart(options), node, undefined, true);
}

export async function composeGroupDown(context: IActionContext, node: ContainerGroupTreeItem): Promise<void> {
return composeGroup(context, (client, options) => client.down(options), node);
return composeGroup(context, (client, options) => client.down(options), node, undefined, true);
}

type AdditionalOptions<TOptions extends CommonOrchestratorCommandOptions> = Omit<TOptions, keyof CommonOrchestratorCommandOptions>;
Expand All @@ -39,7 +39,8 @@ async function composeGroup<TOptions extends CommonOrchestratorCommandOptions>(
context: IActionContext,
composeCommandCallback: (client: IContainerOrchestratorClient, options: TOptions) => Promise<VoidCommandResponse>,
node: ContainerGroupTreeItem,
additionalOptions?: AdditionalOptions<TOptions>
additionalOptions?: AdditionalOptions<TOptions>,
close?: boolean
): Promise<void> {
if (!node) {
await ext.containersTree.refresh(context);
Expand Down Expand Up @@ -70,6 +71,7 @@ async function composeGroup<TOptions extends CommonOrchestratorCommandOptions>(
const taskCRF = new TaskCommandRunnerFactory({
taskName: client.displayName,
cwd: workingDirectory,
...(close !== undefined && { close }),
});

await taskCRF.getCommandRunner()(composeCommandCallback(client, options));
Expand Down
1 change: 1 addition & 0 deletions src/commands/images/buildImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export async function buildImage(context: IActionContext, dockerFileUri: vscode.
taskName: client.displayName,
workspaceFolder: rootFolder,
focus: true,
close: true,
});

await taskCRF.getCommandRunner()(terminalCommand);
Expand Down
3 changes: 2 additions & 1 deletion src/commands/images/pullImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export async function pullImage(context: IActionContext, node?: ImageTreeItem, n
const client = await ext.runtimeManager.getClient();
const taskCRF = new TaskCommandRunnerFactory(
{
taskName: l10n.t('Pull images')
taskName: l10n.t('Pull images'),
close: true,
}
);

Expand Down
3 changes: 2 additions & 1 deletion src/commands/images/pushImage/ImagePushStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export class ImagePushStep extends AzureWizardExecuteStep<PushImageWizardContext
const client = await ext.runtimeManager.getClient();
const taskCRF = new TaskCommandRunnerFactory(
{
taskName: wizardContext.finalTag
taskName: wizardContext.finalTag,
close: true,
}
);

Expand Down
1 change: 1 addition & 0 deletions src/commands/images/runImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ async function runImageCore(context: IActionContext, node: ImageTreeItem | undef
{
taskName: node.fullTag === '<none>' ? node.imageId : node.fullTag,
alwaysRunNew: interactive,
close: !interactive,
}
);

Expand Down
3 changes: 2 additions & 1 deletion src/commands/registries/logOutOfDockerCli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export async function logOutOfDockerCli(context: IActionContext, node?: UnifiedR
const client = await ext.runtimeManager.getClient();
const taskCRF = new TaskCommandRunnerFactory(
{
taskName: 'Container Tools'
taskName: 'Container Tools',
close: true,
}
);

Expand Down
1 change: 1 addition & 0 deletions src/commands/registries/pullImages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ async function pullImages(context: IActionContext, node: UnifiedRegistryItem<unk
const client = await ext.runtimeManager.getClient();
const taskCRF = new TaskCommandRunnerFactory({
taskName: client.displayName,
close: true,
});

await taskCRF.getCommandRunner()(
Expand Down
14 changes: 10 additions & 4 deletions src/runtimes/runners/TaskCommandRunnerFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface TaskCommandRunnerOptions {
alwaysRunNew?: boolean;
rejectOnError?: boolean;
focus?: boolean;
close?: boolean; // When true, auto-close the terminal when the task completes. Default is false.
env?: never; // Environment is not needed and should not be used, because VSCode adds it already (due to using `ExtensionContext.environmentVariableCollection`)
}

Expand Down Expand Up @@ -57,10 +58,15 @@ async function executeAsTask(options: TaskCommandRunnerOptions, command: string,
task.definition.idRandomizer = Math.random();
}

if (options.focus) {
task.presentationOptions = {
focus: true,
};
if (options.focus || options.close) {
const presentationOptions: vscode.TaskPresentationOptions = {};
if (options.focus) {
presentationOptions.focus = true;
}
if (options.close) {
presentationOptions.close = true;
}
task.presentationOptions = presentationOptions;
}

const taskExecution = await vscode.tasks.executeTask(task);
Expand Down