Skip to content

Commit 254fd12

Browse files
mungojamemgarten
authored andcommitted
Fix relative local path support for relative sleet.json
See emgarten#59
1 parent 3497b81 commit 254fd12

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

Sleet.sln

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.27004.2000
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.28531.58
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{98ECD2D1-744F-4DFA-A16A-E13EE596F10C}"
77
EndProject

src/SleetLib/FileSystem/FileSystemFactory.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ public static ISleetFileSystem CreateFileSystem(LocalSettings settings, LocalCac
4848

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

51-
var settingsDir = Path.GetDirectoryName(NuGetUriUtility.GetLocalPath(settings.Path));
51+
var absoluteSettingsPath = NuGetUriUtility.GetAbsolutePath(Directory.GetCurrentDirectory(), settings.Path);
52+
53+
var settingsDir = Path.GetDirectoryName(absoluteSettingsPath);
5254
absolutePath = NuGetUriUtility.GetAbsolutePath(settingsDir, nonEmptyPath);
5355
}
5456
else

test/SleetLib.Tests/FeedTests.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,14 @@ await TestUtility.WalkJsonAsync(target.Root, (file, json, toCheck) =>
124124
[InlineData(@"file:///c:/configPath/sleet.json", @"", @"c:\configPath\")]
125125
[InlineData(@"file:///c:/configPath/sleet.json", @"singleSubFolder", @"c:\configPath\singleSubFolder\")]
126126
[InlineData(@"file:///c:/configPath/sleet.json", @"nestedSubFolder\a", @"c:\configPath\nestedSubFolder\a\")]
127+
[InlineData(@"sleet.json", @"", @"{workingDir}\")]
128+
[InlineData(@"sleet.json", @".\", @"{workingDir}\")]
129+
[InlineData(@"sleet.json", @"singleSubFolder", @"{workingDir}\singleSubFolder\")]
130+
[InlineData(@"sleet.json", @"nestedSubFolder\a", @"{workingDir}\nestedSubFolder\a\")]
127131
public void Feed_LocalTypeSupportsRelativePath(string configPath, string outputPath, string expected)
128132
{
133+
var expectedFull = expected.Replace("{workingDir}", Directory.GetCurrentDirectory());
134+
129135
using (var cache = new LocalCache())
130136
{
131137
var baseUri = UriUtility.CreateUri("https://localhost:8080/testFeed/");
@@ -136,7 +142,7 @@ public void Feed_LocalTypeSupportsRelativePath(string configPath, string outputP
136142
var fileSystem = FileSystemFactory.CreateFileSystem(settings, cache, "local") as PhysicalFileSystem;
137143

138144
Assert.NotNull(fileSystem);
139-
Assert.Equal(expected, fileSystem.LocalRoot);
145+
Assert.Equal(expectedFull, fileSystem.LocalRoot);
140146
}
141147
}
142148

0 commit comments

Comments
 (0)