Skip to content

Commit 150c791

Browse files
committed
Make separate version file for the preview version
1 parent ddc540e commit 150c791

File tree

2 files changed

+8
-25
lines changed

2 files changed

+8
-25
lines changed

src/UnturnedRedistUpdateTool/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ private static async Task<int> Main(string[] args)
9292
}
9393
Console.WriteLine($"Current nuspec version: {currentNuspecVersion}");
9494

95-
var versionTracker = new VersionTracker(redistPath);
95+
var versionTracker = new VersionTracker(redistPath, preview);
9696
var versionInfo = await versionTracker.LoadAsync();
9797

9898
var redistUpdater = new RedistUpdater(managedDirectory, redistPath);

src/UnturnedRedistUpdateTool/VersionTracker.cs

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)