Skip to content

Commit

Permalink
Fix relative local path support for relative sleet.json
Browse files Browse the repository at this point in the history
See #59
  • Loading branch information
mungojam authored and emgarten committed Feb 9, 2019
1 parent 3497b81 commit 254fd12
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Sleet.sln
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2000
# Visual Studio Version 16
VisualStudioVersion = 16.0.28531.58
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{98ECD2D1-744F-4DFA-A16A-E13EE596F10C}"
EndProject
Expand Down
4 changes: 3 additions & 1 deletion src/SleetLib/FileSystem/FileSystemFactory.cs
Expand Up @@ -48,7 +48,9 @@ public static ISleetFileSystem CreateFileSystem(LocalSettings settings, LocalCac

var nonEmptyPath = path == "" ? "." : path;

var settingsDir = Path.GetDirectoryName(NuGetUriUtility.GetLocalPath(settings.Path));
var absoluteSettingsPath = NuGetUriUtility.GetAbsolutePath(Directory.GetCurrentDirectory(), settings.Path);

var settingsDir = Path.GetDirectoryName(absoluteSettingsPath);
absolutePath = NuGetUriUtility.GetAbsolutePath(settingsDir, nonEmptyPath);
}
else
Expand Down
8 changes: 7 additions & 1 deletion test/SleetLib.Tests/FeedTests.cs
Expand Up @@ -124,8 +124,14 @@ public async Task Feed_VerifyBaseUriIsAppliedToLocal(string baseUriString)
[InlineData(@"file:///c:/configPath/sleet.json", @"", @"c:\configPath\")]
[InlineData(@"file:///c:/configPath/sleet.json", @"singleSubFolder", @"c:\configPath\singleSubFolder\")]
[InlineData(@"file:///c:/configPath/sleet.json", @"nestedSubFolder\a", @"c:\configPath\nestedSubFolder\a\")]
[InlineData(@"sleet.json", @"", @"{workingDir}\")]
[InlineData(@"sleet.json", @".\", @"{workingDir}\")]
[InlineData(@"sleet.json", @"singleSubFolder", @"{workingDir}\singleSubFolder\")]
[InlineData(@"sleet.json", @"nestedSubFolder\a", @"{workingDir}\nestedSubFolder\a\")]
public void Feed_LocalTypeSupportsRelativePath(string configPath, string outputPath, string expected)
{
var expectedFull = expected.Replace("{workingDir}", Directory.GetCurrentDirectory());

using (var cache = new LocalCache())
{
var baseUri = UriUtility.CreateUri("https://localhost:8080/testFeed/");
Expand All @@ -136,7 +142,7 @@ public void Feed_LocalTypeSupportsRelativePath(string configPath, string outputP
var fileSystem = FileSystemFactory.CreateFileSystem(settings, cache, "local") as PhysicalFileSystem;

Assert.NotNull(fileSystem);
Assert.Equal(expected, fileSystem.LocalRoot);
Assert.Equal(expectedFull, fileSystem.LocalRoot);
}
}

Expand Down

0 comments on commit 254fd12

Please sign in to comment.