Merge branch 'master' into terminal-docker

This commit is contained in:
Richard Guthrie 2018-01-02 10:46:08 -08:00 коммит произвёл GitHub
Родитель 5578416bef 486e490b57
Коммит 396d638afd
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 49 добавлений и 29 удалений

Просмотреть файл

@ -2,7 +2,6 @@
// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
import * as vscode from 'vscode';
import { extensions, commands, Disposable, window } from 'vscode';
import { AzureAccount }from './azure-account.api';
import { AzureServiceClient, BaseResource } from 'ms-rest-azure';
@ -80,11 +79,9 @@ export function activate(ctx: vscode.ExtensionContext) {
if (!CSTerminal) {
ctx.subscriptions.push(vscode.commands.registerCommand('vscode-terraform-azure.visualize', () => {
activeShell.runTerraformCmdAsync("terraform graph | dot -Tpng > graph.png").then(function(){;
let uri = vscode.Uri.file(join(vscode.workspace.rootPath || '', './graph.png'));
let b = commands.executeCommand('vscode.open', uri);
return Promise.all([b]);});
var iShell : IntegratedShell;
iShell = <IntegratedShell> activeShell;
iShell.visualize();
}));
ctx.subscriptions.push(vscode.commands.registerCommand('vscode-terraform-azure.exectest', () =>{
@ -109,8 +106,6 @@ export function activate(ctx: vscode.ExtensionContext) {
}));
}
// "tf-azure.terminal": "integrated"
var dir = vscode.workspace.workspaceFolders[0].uri.fsPath;
// = vscode.workspace.onDidChangeTextDocument
// let subscriptions: Disposable[] = [];

Просмотреть файл

@ -2,24 +2,33 @@
import * as vscode from 'vscode';
import { BaseShell } from './baseShell';
import { extensions, commands, Disposable, window } from 'vscode';
import { isDockerInstalled, localExecCmd } from './utilities'
import { join } from 'path';
import { extensions, commands, workspace, Disposable, Uri, window, ViewColumn } from 'vscode';
import { TFTerminal, TerminalType } from './shared'
import { Constants } from './constants'
import { isDockerInstalled, localExecCmd } from './utilities'
const fs = require('fs-extra')
export class IntegratedShell extends BaseShell {
static readonly GRAPH_FILE_NAME = './graph.png';
private graphUri : Uri;
protected iTerm = new TFTerminal(
//terminal wrapper
public term = new TFTerminal(
TerminalType.Integrated,
Constants.TerraformTerminalName);
//init shell env and hook up close handler. Close handler ensures if user closes terminal window,
// that extension is notified and can handle appropriately.
protected initShellInternal() {
//set path for
this.graphUri = Uri.file(join(workspace.rootPath || '', IntegratedShell.GRAPH_FILE_NAME));
if ('onDidCloseTerminal' in <any>vscode.window) {
(<any>vscode.window).onDidCloseTerminal((terminal) => {
if (terminal == this.iTerm.terminal) {
if (terminal == this.term.terminal ) {
this.outputLine('Terraform Terminal closed', terminal.name);
this.iTerm.terminal = null;
this.term.terminal = null;
}
});
}
@ -27,24 +36,21 @@ export class IntegratedShell extends BaseShell {
protected runTerraformInternal(TFCommand: string): void {
this.checkCreateTerminal();
var term = this.iTerm.terminal;
var term = this.term.terminal;
term.show();
term.sendText(TFCommand);
return;
}
protected runTerraformAsyncInternal(TFConfiguration: string, TFCommand: string): Promise<any> {
//run tf cmd async and return promise.
protected runTerraformAsyncInternal(TFConfiguration: string, TFCommand: string) : Promise<any>{
this.checkCreateTerminal();
var term = this.iTerm.terminal;
var term = this.term.terminal;
term.show();
let ret = term.sendText(TFCommand);
return Promise.all([ret]);
}
@ -112,7 +118,27 @@ export class IntegratedShell extends BaseShell {
}
protected syncWorkspaceInternal() {
public visualize(): void {
this.deletePng();
this.runTerraformCmdAsync("terraform graph | dot -Tpng > graph.png").then(() => {
this.displayPng();
});
}
private deletePng() : void {
if(fs.existsSync(this.graphUri.path)){
fs.unlinkSync(this.graphUri.path)
}
}
private displayPng(): void {
//add 2 second delay before opening file due to file creation latency
setTimeout(() => {commands.executeCommand('vscode.open', this.graphUri,ViewColumn.Two);}
,2000);
}
protected syncWorkspaceInternal()
{
//not implemented for integrated terminal
}
@ -120,9 +146,8 @@ export class IntegratedShell extends BaseShell {
}
private checkCreateTerminal(): void {
if (this.iTerm.terminal == null) {
this.iTerm.terminal = vscode.window.createTerminal(
if ( this.term.terminal == null ) {
this.term.terminal = vscode.window.createTerminal(
Constants.TerraformTerminalName);
}
}