Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,8 @@ public override string ToString()

internal FileAttributes AdjustAttributes(FileAttributes attributes)
{
if (_fileSystem.Execute.IsLinux &&
_fileSystem.Execute.Path.GetFileName(_location.FullPath).StartsWith('.'))
if ((_fileSystem.Execute.IsLinux || _fileSystem.Execute.IsMac)
&& _fileSystem.Execute.Path.GetFileName(_location.FullPath).StartsWith('.'))
{
attributes |= FileAttributes.Hidden;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public async Task AdjustAttributes_Encrypt_ShouldHaveEncryptedAttribute(string p

[Theory]
[AutoData]
public async Task AdjustAttributes_LeadingDot_ShouldBeHiddenOnLinux(string path)
public async Task AdjustAttributes_LeadingDot_ShouldBeHiddenOnUnix(string path)
{
path = "." + path;
MockFileSystem fileSystem = new();
Expand All @@ -60,7 +60,7 @@ public async Task AdjustAttributes_LeadingDot_ShouldBeHiddenOnLinux(string path)

FileAttributes result = container.AdjustAttributes(FileAttributes.Normal);

if (Test.RunsOnLinux)
if (!Test.RunsOnWindows)
{
await That(result).HasFlag(FileAttributes.Hidden);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,19 @@ public async Task GetAttributes_ShouldReturnAttributes(

await That(result).IsEqualTo(attributes);
}

[Fact]
public async Task GetAttributes_WhenDotEntry_ShouldHaveHiddenFlag()
{
Skip.If(Test.RunsOnWindows);

const string path = ".env";
FileAttributes result;

FileSystem.File.WriteAllText(path, null);

result = FileSystem.File.GetAttributes(path);

await That(result).HasFlag(FileAttributes.Hidden);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,30 @@ public async Task SetAttributes_ShouldOnlyWork_OnWindows(FileAttributes attribut
await That(result).IsEqualTo(FileAttributes.Normal);
}
}

[Theory]
[AutoData]
public async Task Attributes_WhenDotFile_ShouldHaveHiddenFlag(bool isFile)
{
Skip.If(Test.RunsOnWindows);

const string path = ".env";

FileAttributes result;

if (isFile)
{
FileSystem.File.WriteAllText(path, null);

result = FileSystem.FileInfo.New(path).Attributes;
}
else
{
FileSystem.Directory.CreateDirectory(path);

result = FileSystem.DirectoryInfo.New(path).Attributes;
}

await That(result).HasFlag(FileAttributes.Hidden);
}
}
Loading