File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -106,7 +106,12 @@ export abstract class TemplateProviderBase implements Disposable {
106106 }
107107
108108 public async getBackupTemplateVersion ( ) : Promise < string > {
109- return ( await AzExtFsExtra . readFile ( await this . getBackupVersionPath ( ) ) ) . toString ( ) . trim ( ) ;
109+ const versionPath = await this . getBackupVersionPath ( ) ;
110+ if ( await AzExtFsExtra . pathExists ( versionPath ) ) {
111+ const content = await AzExtFsExtra . readFile ( versionPath ) ;
112+ return content ? content . toString ( ) . trim ( ) : '' ;
113+ }
114+ return '' ;
110115 }
111116
112117 public async updateBackupTemplateVersion ( version : string ) : Promise < void > {
Original file line number Diff line number Diff line change @@ -37,7 +37,11 @@ export class JavaTemplateProvider extends ScriptTemplateProvider {
3737 public async getLatestTemplateVersion ( ) : Promise < string > {
3838 this . validateGradleProject ( ) ;
3939 const pomPath : string = path . join ( this . getProjectPath ( ) , pomXmlFileName ) ;
40- const pomContents : string = ( await AzExtFsExtra . readFile ( pomPath ) ) . toString ( ) ;
40+ const pomFileContent = await AzExtFsExtra . readFile ( pomPath ) ;
41+ if ( ! pomFileContent ) {
42+ throw new Error ( localize ( 'failedToReadPom' , 'Failed to read pom.xml file.' ) ) ;
43+ }
44+ const pomContents : string = pomFileContent . toString ( ) ;
4145 const match : RegExpMatchArray | null = pomContents . match ( / < a z u r e .f u n c t i o n s .m a v e n .p l u g i n .v e r s i o n > ( .* ) < \/ a z u r e .f u n c t i o n s .m a v e n .p l u g i n .v e r s i o n > / i) ;
4246 if ( ! match ) {
4347 throw new Error ( localize ( 'failedToDetectPluginVersion' , 'Failed to detect Azure Functions maven plugin version.' ) ) ;
You can’t perform that action at this time.
0 commit comments