import * as vscode from "vscode" ; import { TestHub , testExplorerExtensionId } from "vscode-test-adapter-api" ; import { Log , TestAdapterRegistrar } from "vscode-test-adapter-util" ; import { Adapter } from "./adapter" ; import { OUTPUT_CHANNEL } from "./core/shared/logger" ; import { UIExtensionMethods } from "./infrastructure/ui-extension-methods" ; import { ProjectType } from "./model/enums/project-type.enum" ; let testExplorerAdapters = [ ] ; export async function activate ( context ) { const workspaceFolder = ( vscode . workspace . workspaceFolders || [ ] ) [ 0 ] ; const channel = vscode . window . createOutputChannel ( OUTPUT_CHANNEL ) ; const log = new Log ( "AngularKarmaExplorer" , workspaceFolder , "AngularKarma Explorer Log" ) ; context . subscriptions . push ( log ) ; const testExplorerExtension = vscode . extensions . getExtension < TestHub > ( testExplorerExtensionId ) ; if ( log . enabled ) { log . info ( `Test Explorer ${ testExplorerExtension ? "" : "not " }found` ) ; } if ( testExplorerExtension ) { const testHub = testExplorerExtension . exports ; const registerCommand = ( command , callback ) => { context . subscriptions . push ( vscode . commands . registerCommand ( command , callback ) ) ; } ; const uiExtensionMethods = new UIExtensionMethods ( ) ; context . subscriptions . push ( new TestAdapterRegistrar ( testHub , workspaceFolder => { const projectType = vscode . workspace . getConfiguration ( "angularKarmaTestExplorer" , workspaceFolder . uri ) . get ( "projectType" ) as ProjectType ; let testExplorerAdapter = new Adapter ( workspaceFolder , log , channel , projectType ) ; testExplorerAdapters . push ( testExplorerAdapter ) ; if ( uiExtensionMethods . isAngularCLIProject ( testExplorerAdapter , projectType ) ) { registerCommand ( "angular-karma-test-explorer.select-project" , async ( ) => uiExtensionMethods . createSelectProjectQuickPick ( testExplorerAdapter ) ) ; } return testExplorerAdapter ; } , log ) ) ; } } export async function deactivate ( ) { for ( const testExplorerAdapter of testExplorerAdapters ) { testExplorerAdapter . dispose ( ) ; } }