@@ -78,21 +78,21 @@ export default class QnamakerConvert extends Command {
7878
7979 private async writeOutput ( convertedObject : any , flags : any , isQnA : boolean ) {
8080 let filePath = await file . generateNewFilePath ( flags . out , flags . in , isQnA , '' , fileExtEnum . QnAFile )
81+ const validatedPath = utils . validatePath ( filePath , '' , flags . force )
8182 try {
8283 if ( isQnA ) {
83- let validatedPath = utils . validatePath ( filePath , '' , flags . force )
8484 await fs . writeFile ( validatedPath , JSON . stringify ( convertedObject . finalQnAJSON , null , 2 ) , 'utf-8' )
8585 if ( convertedObject . finalQnAAlterations ) {
8686 let filePathAlterations = await file . generateNewFilePath ( flags . out , flags . in , isQnA , 'alterations_' , fileExtEnum . QnAFile )
87- let validatedPath = utils . validatePath ( filePathAlterations , '' , flags . force )
88- await fs . writeFile ( validatedPath , JSON . stringify ( convertedObject . finalQnAAlterations , null , 2 ) , 'utf-8' )
87+ const validatedPathAlter = utils . validatePath ( filePathAlterations , '' , flags . force )
88+ await fs . writeFile ( validatedPathAlter , JSON . stringify ( convertedObject . finalQnAAlterations , null , 2 ) , 'utf-8' )
8989 }
9090 } else {
91- await fs . writeFile ( filePath , convertedObject , 'utf-8' )
91+ await fs . writeFile ( validatedPath , convertedObject , 'utf-8' )
9292 }
9393 } catch ( err ) {
94- throw new CLIError ( 'Unable to write file - ' + filePath + ' Error: ' + err . message )
94+ throw new CLIError ( 'Unable to write file - ' + validatedPath + ' Error: ' + err . message )
9595 }
96- this . log ( 'Successfully wrote QnA model to ' + filePath )
96+ this . log ( 'Successfully wrote QnA model to ' + validatedPath )
9797 }
9898}
0 commit comments