Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Don't break on not indexable folders #51

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
12 changes: 9 additions & 3 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
"version": 1,
"isRoot": true,
"tools": {
"extLauncher": {
"version": "1.0.0",
"fantomas": {
"version": "6.2.3",
"commands": [
"extLauncher"
"fantomas"
]
},
"paket": {
"version": "8.0.0",
"commands": [
"paket"
]
}
}
Expand Down
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
root = true

[paket.*]
insert_final_newline = false

[*.{fs,fsx}]
fsharp_multiline_bracket_style = stroustrup
fsharp_multi_line_lambda_closing_newline = true
fsharp_bar_before_discriminated_union_declaration = true
fsharp_keep_max_number_of_blank_lines = 1
fsharp_record_multiline_formatter = number_of_items
fsharp_max_record_number_of_items = 1
fsharp_array_or_list_multiline_formatter = number_of_items
fsharp_max_array_or_list_number_of_items = 1
557 changes: 557 additions & 0 deletions .paket/Paket.Restore.targets

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions Install-as-dotnet-tool.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$ToolName = "ExtLauncher"
dotnet pack --configuration Release
dotnet tool uninstall $ToolName --global
dotnet tool install $ToolName --add-source .\$ToolName\nupkg\ --global
4 changes: 4 additions & 0 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@ECHO OFF

dotnet tool restore
dotnet build -- %*
104 changes: 62 additions & 42 deletions extLauncher.Tests/AppTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,69 +5,89 @@ open Xunit

[<Fact>]
let ``should load a folder`` () =
let folderPath = "/test"
let folderPath = FolderPath "/test"
let pattern = "*.ext"

let folder =
let loadFiles _ _ =
[| "/test/file2.ext", "file2"
"/test/file1.ext", "file1" |]
App.loadFolder loadFiles
{ Path = folderPath
Pattern = Pattern.from pattern false
Launchers = Array.empty }
folder =! Some
{ Id = folderPath
Pattern = pattern
IsRegex = false
Files =
[| File.create "/test/file1.ext" "file1"
File.create "/test/file2.ext" "file2" |]
Launchers = Array.empty }
let loadFiles _ _ = [|
FilePath "/test/file2.ext", FileName "file2"
FilePath "/test/file1.ext", FileName "file1"
|]

App.loadFolder loadFiles {
Path = folderPath
Pattern = Pattern.init pattern false
Launchers = Array.empty
}

folder
=! Some {
Path = folderPath
Pattern = Pattern.init pattern false
Files = [|
File.create (FilePath "/test/file1.ext") (FileName "file1")
File.create (FilePath "/test/file2.ext") (FileName "file2")
|]
Launchers = Array.empty
}

[<Fact>]
let ``should not load a folder if no result`` () =
let folder =
let loadFiles _ _ = Array.empty
App.loadFolder loadFiles
{ Path = ""
Pattern = Pattern.from "" false
Launchers = Array.empty }

App.loadFolder loadFiles {
Path = FolderPath ""
Pattern = Pattern.init "" false
Launchers = Array.empty
}

folder =! None

[<Fact>]
let ``refresh should synchronize files`` () =
let newFolder =
let loadFiles _ _ =
[| "file1", ""
"file3", "" |]
let loadFiles _ _ = [|
FilePath "file1", FileName ""
FilePath "file3", FileName ""
|]

let save = id
{ Id = ""
Pattern = ""
IsRegex = false
Files =
[| File.create "file1" ""
File.create "file2" "" |]
Launchers = Array.empty }

{
Path = FolderPath ""
Pattern = Pattern.init "" false
Files = [|
File.create (FilePath "file1") (FileName "")
File.create (FilePath "file2") (FileName "")
|]
Launchers = Array.empty
}
|> App.refresh loadFiles save
|> Option.get

newFolder.Files.[0].Id =! "file1"
newFolder.Files.[1].Id =! "file3"
newFolder.Files.[0].Path.value =! "file1"
newFolder.Files.[1].Path.value =! "file3"

[<Fact>]
let ``refresh should keep triggers`` () =
let newFolder =
let loadFiles _ _ =
[| "file1", ""
"file2", "" |]
let loadFiles _ _ = [|
FilePath "file1", FileName ""
FilePath "file2", FileName ""
|]

let save = id
{ Id = ""
Pattern = ""
IsRegex = false
Files =
[| File.create "file1" "" |> File.triggered
File.create "file2" "" |]
Launchers = Array.empty }

{
Path = FolderPath ""
Pattern = Pattern.init "" false
Files = [|
File.create (FilePath "file1") (FileName "") |> File.triggered
File.create (FilePath "file2") (FileName "")
|]
Launchers = Array.empty
}
|> App.refresh loadFiles save
|> Option.get

Expand Down
Loading
Loading