@@ -16,39 +16,22 @@ public class VersionTracker
1616 private static readonly JsonSerializerOptions JsonSerializerOptions = new ( ) { WriteIndented = true } ;
1717 private readonly string _versionFilePath ;
1818
19- public VersionTracker ( string redistPath )
19+ public VersionTracker ( string redistPath , bool preview )
2020 {
21- _versionFilePath = Path . Combine ( redistPath , "version-info .json" ) ;
21+ _versionFilePath = Path . Combine ( redistPath , preview ? "version.preview.json" : "version .json") ;
2222 }
2323
2424 public async Task < VersionInfo ? > LoadAsync ( )
2525 {
2626 if ( ! File . Exists ( _versionFilePath ) )
2727 return null ;
28-
29- try
30- {
31- var json = await File . ReadAllTextAsync ( _versionFilePath ) ;
32- return JsonSerializer . Deserialize < VersionInfo > ( json ) ;
33- }
34- catch ( Exception ex )
35- {
36- Console . WriteLine ( $ "Could not load version info: { ex } ") ;
37- return null ;
38- }
28+ var json = await File . ReadAllTextAsync ( _versionFilePath ) ;
29+ return JsonSerializer . Deserialize < VersionInfo > ( json ) ;
3930 }
4031
41- public async Task SaveAsync ( VersionInfo versionInfo )
32+ public async Task SaveAsync ( VersionInfo info )
4233 {
43- try
44- {
45- var json = JsonSerializer . Serialize ( versionInfo , JsonSerializerOptions ) ;
46- await File . WriteAllTextAsync ( _versionFilePath , json ) ;
47- Console . WriteLine ( $ "Version info saved to: { _versionFilePath } ") ;
48- }
49- catch ( Exception ex )
50- {
51- Console . WriteLine ( $ "Could not save version info: { ex } ") ;
52- }
34+ var json = JsonSerializer . Serialize ( info , JsonSerializerOptions ) ;
35+ await File . WriteAllTextAsync ( _versionFilePath , json ) ;
5336 }
5437}
0 commit comments