@@ -33,7 +33,7 @@ async function removeTestInfraStructure() {
3333 deleteFolder ( path . resolve ( `./.azure-devops` ) ) ;
3434
3535 await updatePackageJsonFile ( ) ;
36- await updateLaunchJsonFile ( ) ;
36+ await updateLaunchJsonFile ( "excel" ) ;
3737 // delete this script
3838 await unlinkFileAsync ( "./convertToSingleHost.js" ) ;
3939 await deleteSupportFiles ( ) ;
@@ -62,13 +62,34 @@ async function updatePackageJsonFile() {
6262 await writeFileAsync ( packageJson , JSON . stringify ( content , null , 2 ) ) ;
6363}
6464
65- async function updateLaunchJsonFile ( ) {
65+ async function updateLaunchJsonFile ( host ) {
6666 // Remove 'Debug Tests' configuration from launch.json
6767 const launchJson = `.vscode/launch.json` ;
6868 const launchJsonContent = await readFileAsync ( launchJson , "utf8" ) ;
69- 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;
70- const updatedContent = launchJsonContent . replace ( regex , "" ) ;
71- await writeFileAsync ( launchJson , updatedContent ) ;
69+ let content = JSON . parse ( launchJsonContent ) ;
70+ content . configurations = content . configurations . filter ( function ( config ) {
71+ return config . name . startsWith ( getHostName ( host ) ) ;
72+ } ) ;
73+ await writeFileAsync ( launchJson , JSON . stringify ( content , null , 2 ) ) ;
74+ }
75+
76+ function getHostName ( host ) {
77+ switch ( host ) {
78+ case "excel" :
79+ return "Excel" ;
80+ case "onenote" :
81+ return "OneNote" ;
82+ case "outlook" :
83+ return "Outlook" ;
84+ case "powerpoint" :
85+ return "PowerPoint" ;
86+ case "project" :
87+ return "Project" ;
88+ case "word" :
89+ return "Word" ;
90+ default :
91+ throw new Error ( `'${ host } ' is not a supported host.` ) ;
92+ }
7293}
7394
7495function deleteFolder ( folder ) {
@@ -114,10 +135,6 @@ async function updatePackageJsonForXMLManifest() {
114135 const data = await readFileAsync ( packageJson , "utf8" ) ;
115136 let content = JSON . parse ( data ) ;
116137
117- // Remove scripts that are only used with JSON manifest
118- delete content . scripts [ "signin" ] ;
119- delete content . scripts [ "signout" ] ;
120-
121138 // Write updated JSON to file
122139 await writeFileAsync ( packageJson , JSON . stringify ( content , null , 2 ) ) ;
123140}
@@ -227,9 +244,10 @@ if (projectName) {
227244 const cmdLine = `npx office-addin-manifest modify ${ manifestPath } -g ${ appId } -d ${ projectName } ` ;
228245 childProcess . exec ( cmdLine , ( error , stdout ) => {
229246 if ( error ) {
230- Promise . reject ( stdout ) ;
247+ console . error ( `Error updating the manifest: ${ error } ` ) ;
248+ process . exitCode = 1 ;
231249 } else {
232- Promise . resolve ( ) ;
250+ console . log ( stdout ) ;
233251 }
234252 } ) ;
235253}
0 commit comments