@@ -16,7 +16,6 @@ import { openMessagePane, vectorMessage } from "./messagePane";
1616
1717import {
1818 environmentDataCache ,
19- environmentNodeDataType ,
2019 getClicastArgsFromTestNode ,
2120 getClicastArgsFromTestNodeAsList ,
2221 getEnviroNameFromID ,
@@ -237,7 +236,7 @@ export async function cleanProjectEnvironment(
237236 // if we are in server mode, close any existing connection to the environment
238237 if ( globalEnviroDataServerActive ) await closeConnection ( enviroPath ) ;
239238
240- executeWithRealTimeEchoWithProgress (
239+ await executeWithRealTimeEchoWithProgress (
241240 manageCommandToUse ,
242241 manageArgs ,
243242 projectLocation ,
@@ -608,87 +607,66 @@ export async function updateAllOpenedProjects() {
608607/**
609608 * Updates the project data for the given environment
610609 * @param enviroPath Path to the environment
611- * @param enviroName Name of the environment
610+ * @param forceUpdate Whether to force update even if auto-update is disabled
612611 */
613612export async function updateProjectData (
614613 enviroPath : string ,
615614 forceUpdate = false
616615) {
617- // Only update if the current env is embedded in a project and the setting is enabled
618- // or we force the update by actively clicking on the Update Project Button
619- const normalizedEnviroPath = normalizePath ( enviroPath ) ;
616+ const normalizedPath = normalizePath ( enviroPath ) ;
620617 const config = vscode . workspace . getConfiguration ( "vectorcastTestExplorer" ) ;
621- const autoUpdateEnabled = config . get < boolean > (
618+ const autoUpdate = config . get < boolean > (
622619 "automaticallyUpdateManageProject" ,
623620 true
624621 ) ;
625622
626- const envIsInProject : boolean = envIsEmbeddedInProject ( normalizedEnviroPath ) ;
627-
628- if ( envIsInProject && ( autoUpdateEnabled || forceUpdate ) ) {
629- const enviroName = path . basename ( normalizedEnviroPath ) ;
630- const blockUpdate =
631- await checkIfEnvironmentIsBuildMultipleTimes ( enviroName ) ;
632- if ( blockUpdate ) {
633- // Show an information message with two options.
634- const selection = await vscode . window . showInformationMessage (
635- `Updating the project data is currently blocked because ${ enviroName } is built in multiple testsuites. You can clean the other Environments now and the project will be updated.` ,
636- "Cancel" ,
637- "Clean other Environments"
638- ) ;
639-
640- if ( selection === "Clean other Environments" ) {
641- // Delete the build folders of the other builds.
642- await deleteOtherBuildFolders ( normalizedEnviroPath ) ;
643-
644- // Update Project after cleaning the other environments
645- const enviroData : environmentNodeDataType =
646- getEnviroNodeData ( normalizedEnviroPath ) ;
647- const projectFilePath : string = enviroData . projectPath ;
648- const projectName : string = path . basename ( projectFilePath ) ;
649- const projectLocation : string = path . dirname ( projectFilePath ) ;
650- const manageArgs : string [ ] = [
651- `-p${ projectName } ` ,
652- `--level=${ enviroData . displayName } ` ,
653- "--apply-changes" ,
654- "--force" ,
655- ] ;
623+ // Only update if the current env is embedded in a project and the setting is enabled
624+ // or we force the update by actively clicking on the Update Project Button
625+ if (
626+ ! envIsEmbeddedInProject ( normalizedPath ) ||
627+ ( ! autoUpdate && ! forceUpdate )
628+ ) {
629+ return ;
630+ }
656631
657- openMessagePane ( ) ;
658- const progressMessage = "Updating project data ..." ;
659- await executeWithRealTimeEchoWithProgress (
660- manageCommandToUse ,
661- manageArgs ,
662- projectLocation ,
663- progressMessage
664- ) ;
665- } else {
666- // User chose Cancel; do nothing.
667- return ;
668- }
669- } else {
670- const enviroData : environmentNodeDataType =
671- getEnviroNodeData ( normalizedEnviroPath ) ;
672- const projectFilePath : string = enviroData . projectPath ;
673- const projectName : string = path . basename ( projectFilePath ) ;
674- const projectLocation : string = path . dirname ( projectFilePath ) ;
675- const manageArgs : string [ ] = [
676- `-p${ projectName } ` ,
677- `--level=${ enviroData . displayName } ` ,
678- "--apply-changes" ,
679- "--force" ,
680- ] ;
681-
682- openMessagePane ( ) ;
683- const progressMessage = "Updating project data ..." ;
684- await executeWithRealTimeEchoWithProgress (
685- manageCommandToUse ,
686- manageArgs ,
687- projectLocation ,
688- progressMessage
689- ) ;
690- }
632+ const enviroName = path . basename ( normalizedPath ) ;
633+
634+ // Check if the environment is built in multiple test suites
635+ const shouldBlock = await checkIfEnvironmentIsBuildMultipleTimes ( enviroName ) ;
636+
637+ if ( shouldBlock ) {
638+ // Show an information message with two options.
639+ const choice = await vscode . window . showInformationMessage (
640+ `Updating the project data is currently blocked because ${ enviroName } is built in multiple testsuites. You can clean the other Environments now and the project will be updated.` ,
641+ "Cancel" ,
642+ "Clean other Environments"
643+ ) ;
644+
645+ if ( choice !== "Clean other Environments" ) return ;
646+
647+ // Delete the build folders of the other builds.
648+ await deleteOtherBuildFolders ( normalizedPath ) ;
691649 }
650+
651+ // Update Project after cleaning the other environments OR if update is not blocked
652+ const { projectPath, displayName } = getEnviroNodeData ( normalizedPath ) ;
653+ const projectName = path . basename ( projectPath ) ;
654+ const projectLocation = path . dirname ( projectPath ) ;
655+ const manageArgs = [
656+ `-p${ projectName } ` ,
657+ `--level=${ displayName } ` ,
658+ "--apply-changes" ,
659+ "--force" ,
660+ ] ;
661+
662+ openMessagePane ( ) ;
663+ const progressMessage = "Updating project data ..." ;
664+ await executeWithRealTimeEchoWithProgress (
665+ manageCommandToUse ,
666+ manageArgs ,
667+ projectLocation ,
668+ progressMessage
669+ ) ;
692670}
693671
694672// Load Test Script - server logic included -----------------------------------------
0 commit comments