-
-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/belav/csharpier
- Loading branch information
Showing
29 changed files
with
727 additions
and
372 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
namespace CSharpier.Cli.EditorConfig; | ||
|
||
internal static class Globber | ||
{ | ||
private static readonly GlobMatcherOptions globOptions = | ||
new() | ||
{ | ||
MatchBase = true, | ||
Dot = true, | ||
AllowWindowsPaths = true, | ||
AllowSingleBraceSets = true, | ||
}; | ||
|
||
public static GlobMatcher Create(string files, string directory) | ||
{ | ||
var pattern = FixGlob(files, directory); | ||
return GlobMatcher.Create(pattern, globOptions); | ||
} | ||
|
||
private static string FixGlob(string glob, string directory) | ||
{ | ||
glob = glob.IndexOf('/') switch | ||
{ | ||
-1 => "**/" + glob, | ||
0 => glob[1..], | ||
_ => glob | ||
}; | ||
directory = directory.Replace(@"\", "/"); | ||
if (!directory.EndsWith("/")) | ||
{ | ||
directory += "/"; | ||
} | ||
|
||
return directory + glob; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.