From ad06a4e06cbaeea22caadfe82ecebeef859a7593 Mon Sep 17 00:00:00 2001 From: Muhammad Danish Date: Tue, 28 Nov 2023 04:02:59 +0500 Subject: [PATCH] Expand environment variables in input paths (#484) --- src/WingetCreateCLI/Commands/BaseCommand.cs | 3 ++- src/WingetCreateCLI/Commands/SubmitCommand.cs | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/WingetCreateCLI/Commands/BaseCommand.cs b/src/WingetCreateCLI/Commands/BaseCommand.cs index 8ea0e26f..3c4ed842 100644 --- a/src/WingetCreateCLI/Commands/BaseCommand.cs +++ b/src/WingetCreateCLI/Commands/BaseCommand.cs @@ -161,10 +161,11 @@ protected static string SaveManifestDirToLocalPath( DefaultLocaleManifest defaultLocaleManifest = manifests.DefaultLocaleManifest; List localeManifests = manifests.LocaleManifests; + outputDir = Environment.ExpandEnvironmentVariables(outputDir); string version = versionManifest.PackageVersion; string packageId = versionManifest.PackageIdentifier; string manifestDir = Utils.GetAppManifestDirPath(packageId, version); - string fullDirPath = Path.Combine(outputDir, manifestDir); + string fullDirPath = Path.GetFullPath(Path.Combine(outputDir, manifestDir)); try { diff --git a/src/WingetCreateCLI/Commands/SubmitCommand.cs b/src/WingetCreateCLI/Commands/SubmitCommand.cs index 9d7bbd84..ad52adaa 100644 --- a/src/WingetCreateCLI/Commands/SubmitCommand.cs +++ b/src/WingetCreateCLI/Commands/SubmitCommand.cs @@ -97,15 +97,17 @@ public override async Task Execute() private async Task SubmitManifest() { - if (File.Exists(this.Path) && ValidateManifest(this.Path)) + string expandedPath = System.Environment.ExpandEnvironmentVariables(this.Path); + + if (File.Exists(expandedPath) && ValidateManifest(expandedPath)) { Manifests manifests = new Manifests(); - manifests.SingletonManifest = Serialization.DeserializeFromPath(this.Path); + manifests.SingletonManifest = Serialization.DeserializeFromPath(expandedPath); return await this.GitHubSubmitManifests(manifests, this.PRTitle); } - else if (Directory.Exists(this.Path) && ValidateManifest(this.Path)) + else if (Directory.Exists(expandedPath) && ValidateManifest(expandedPath)) { - List manifestContents = Directory.GetFiles(this.Path).Select(f => File.ReadAllText(f)).ToList(); + List manifestContents = Directory.GetFiles(expandedPath).Select(f => File.ReadAllText(f)).ToList(); Manifests manifests = Serialization.DeserializeManifestContents(manifestContents); return await this.GitHubSubmitManifests(manifests, this.PRTitle); }