Skip to content

Commit

Permalink
Remove dependency on PowerShell Extension.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdriscoll committed Oct 12, 2023
1 parent c457865 commit a955788
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
5 changes: 4 additions & 1 deletion src/commands/debugger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,14 @@ export class UniversalDebugAdapter implements vscode.DebugAdapter {
const protocolMessage = JSON.parse(message) as DebugProtocol.ProtocolMessage;
this.handleMessage(protocolMessage);
});

this.hubConnection.onclose(() => {
vscode.window.showInformationMessage("Disconnected from PowerShell Universal Debugger.");
});
}

private hubConnection: HubConnection;
private sendMessage = new vscode.EventEmitter<DebugProtocol.ProtocolMessage>();
private sequence: number = 1;

readonly onDidSendMessage: vscode.Event<DebugProtocol.ProtocolMessage> = this.sendMessage.event;

Expand Down
14 changes: 0 additions & 14 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,6 @@ import { registerModuleCommands } from './commands/modules';
import { registerDebuggerCommands } from './commands/debugger';

export async function activate(context: vscode.ExtensionContext) {

var extension = vscode.extensions.getExtension("ms-vscode.PowerShell");
if (!extension) {
extension = vscode.extensions.getExtension("ms-vscode.PowerShell-Preview");
}

if (!extension) {
vscode.window.showErrorMessage("PowerShell Universal requires the Microsoft PowerShell or PowerShell Preview extension.");
return;
}

if (!extension.isActive)
await extension.activate();

registerConnectCommands(context);

const universal = new Universal(context);
Expand Down
5 changes: 5 additions & 0 deletions src/universal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ export class Universal {
}
}

if (!vscode.window.terminals.find(x => x.name === "PowerShell Extension")) {
Container.connected = true;
return;
}

Container.universal.sendTerminalCommand(`Import-Module (Join-Path '${__dirname}' 'Universal.VSCode.psm1')`);
Container.universal.sendTerminalCommand(`Install-UniversalModule -Version '${version}'`);
Container.universal.sendTerminalCommand(`Connect-PSUServer -ComputerName '${url}' -AppToken '${appToken}'`);
Expand Down

0 comments on commit a955788

Please sign in to comment.