@@ -32,7 +32,7 @@ async function modifyProjectForSingleHost(host) {
3232 }
3333 await convertProjectToSingleHost ( host ) ;
3434 await updatePackageJsonForSingleHost ( host ) ;
35- await updateLaunchJsonFile ( ) ;
35+ await updateLaunchJsonFile ( host ) ;
3636}
3737
3838async function convertProjectToSingleHost ( host ) {
@@ -100,13 +100,34 @@ async function updatePackageJsonForSingleHost(host) {
100100 await writeFileAsync ( packageJson , JSON . stringify ( content , null , 2 ) ) ;
101101}
102102
103- async function updateLaunchJsonFile ( ) {
103+ async function updateLaunchJsonFile ( host ) {
104104 // Remove 'Debug Tests' configuration from launch.json
105105 const launchJson = `.vscode/launch.json` ;
106106 const launchJsonContent = await readFileAsync ( launchJson , "utf8" ) ;
107- const regex = / ( .+ { \r ? \n .* " n a m e " : " D e b u g (?: U I | U n i t ) T e s t s " , \r ? \n (?: .* \r ? \n ) * ?.* } , .* \r ? \n ) / gm;
108- const updatedContent = launchJsonContent . replace ( regex , "" ) ;
109- await writeFileAsync ( launchJson , updatedContent ) ;
107+ let content = JSON . parse ( launchJsonContent ) ;
108+ content . configurations = content . configurations . filter ( function ( config ) {
109+ return config . name . startsWith ( getHostName ( host ) ) ;
110+ } ) ;
111+ await writeFileAsync ( launchJson , JSON . stringify ( content , null , 2 ) ) ;
112+ }
113+
114+ function getHostName ( host ) {
115+ switch ( host ) {
116+ case "excel" :
117+ return "Excel" ;
118+ case "onenote" :
119+ return "OneNote" ;
120+ case "outlook" :
121+ return "Outlook" ;
122+ case "powerpoint" :
123+ return "PowerPoint" ;
124+ case "project" :
125+ return "Project" ;
126+ case "word" :
127+ return "Word" ;
128+ default :
129+ throw new Error ( `'${ host } ' is not a supported host.` ) ;
130+ }
110131}
111132
112133function deleteFolder ( folder ) {
0 commit comments