Skip to content

Commit

Permalink
Install Fantomas and add check to build pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf authored and dsyme committed Jun 2, 2022
1 parent 6ffcec3 commit 2d63df8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
]
}
}
}
}
33 changes: 32 additions & 1 deletion build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,40 @@ Target.create "Help" (fun _ ->
printfn ""
)

let sourceFiles =
!! "src/**/*.fs" ++ "src/**/*.fsi" ++ "build.fsx"
-- "src/**/obj/**/*.fs"
-- "src/AssemblyInfo*.fs"

Target.create "Format" (fun _ ->
let result =
sourceFiles
|> Seq.map (sprintf "\"%s\"")
|> String.concat " "
|> DotNet.exec id "fantomas"

if not result.OK then
printfn "Errors while formatting all files: %A" result.Messages)

Target.create "CheckFormat" (fun _ ->
let result =
sourceFiles
|> Seq.map (sprintf "\"%s\"")
|> String.concat " "
|> sprintf "%s --check"
|> DotNet.exec id "fantomas"

if result.ExitCode = 0 then
Trace.log "No files need formatting"
elif result.ExitCode = 99 then
failwith "Some files need formatting, run `dotnet fake build -t Format` to format them"
else
Trace.logf "Errors while formatting: %A" result.Errors
failwith "Unknown errors while formatting")

Target.create "All" ignore

"Clean" ==> "AssemblyInfo" ==> "Build"
"Clean" ==> "AssemblyInfo" ==> "CheckFormat" ==> "Build"
"Build" ==> "CleanDocs" ==> "GenerateDocs" ==> "All"
"Build" ==> "NuGet" ==> "All"
"Build" ==> "All"
Expand Down

0 comments on commit 2d63df8

Please sign in to comment.