-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add styleChecker.fsx script to check style of our F#, TS and YML codes. The `git respore package.json` command in the styleChecker.fsx script was failing with the following error, even when I was running the `git config --global --add safe.directory '*'` command in both the styleChecker.fsx script and in the CI. In the [1] issue, it's suggested by someone to use --system instead of --global in the mentioned command, when the git command is running in a container, which solved the problem. ``` fatal: detected dubious ownership in repository at '/__w/conventions/conventions' To add an exception for this directory, call: git config --global --add safe.directory /__w/conventions/conventions Error when running 'git restore package.json' Fsdk.Process+ProcessFailed: Exception of type 'Fsdk.Process+ProcessFailed' was thrown. at Fsdk.Process.ProcessResult.Unwrap(String errMsg) at Fsdk.Process.ProcessResult.UnwrapDefault() at FSI_0002.RunPrettier(String arguments) at <StartupCode$FSI_0002>.$FSI_0002.main@() Stopped due to error Error: Process completed with exit code 1. ``` [1] actions/checkout#1048
- Loading branch information
1 parent
73ada7e
commit 18c175b
Showing
2 changed files
with
100 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#!/usr/bin/env -S dotnet fsi | ||
|
||
#r "nuget: Fsdk, Version=0.6.0--date20230326-0544.git-5c4f55b" | ||
|
||
open Fsdk | ||
open Fsdk.Process | ||
|
||
let StyleFSharpFiles() = | ||
Process | ||
.Execute( | ||
{ | ||
Command = "dotnet" | ||
Arguments = "new tool-manifest --force" | ||
}, | ||
Process.Echo.Off | ||
) | ||
.UnwrapDefault() | ||
|> ignore | ||
|
||
Process | ||
.Execute( | ||
{ | ||
Command = "dotnet" | ||
Arguments = | ||
"tool install fantomless-tool --version 4.7.997-prerelease" | ||
}, | ||
Process.Echo.Off | ||
) | ||
.UnwrapDefault() | ||
|> ignore | ||
|
||
Process | ||
.Execute( | ||
{ | ||
Command = "dotnet" | ||
Arguments = "fantomless --recurse ." | ||
}, | ||
Process.Echo.Off | ||
) | ||
.UnwrapDefault() | ||
|> ignore | ||
|
||
let RunPrettier(arguments: string) = | ||
let processResult = | ||
Process | ||
.Execute( | ||
{ | ||
Command = "npx" | ||
Arguments = $"prettier {arguments}" | ||
}, | ||
Process.Echo.All | ||
) | ||
.Result | ||
|
||
match processResult with | ||
| ProcessResultState.Success output -> output | ||
| ProcessResultState.WarningsOrAmbiguous output -> output.StdOut | ||
| ProcessResultState.Error(exitCode, output) -> | ||
failwith( | ||
sprintf | ||
"Finished with an error of exitcode %i: %s" | ||
exitCode | ||
output.StdErr | ||
) | ||
|> printfn "%A" | ||
|
||
// Since after installing commitlint dependencies package.json file changes, we need to | ||
// run the following command to ignore package.json file | ||
Process | ||
.Execute( | ||
{ | ||
Command = "git" | ||
Arguments = "restore package.json" | ||
}, | ||
Process.Echo.Off | ||
) | ||
.UnwrapDefault() | ||
|> ignore | ||
|
||
let StyleTypeScriptFiles() = | ||
RunPrettier "--quote-props=consistent --write ./**/*.ts" | ||
|
||
let StyleYmlFiles() = | ||
RunPrettier "--quote-props=consistent --write ./**/*.yml" | ||
|
||
StyleFSharpFiles() | ||
StyleTypeScriptFiles() | ||
StyleYmlFiles() | ||
|
||
Process | ||
.Execute( | ||
{ | ||
Command = "git" | ||
Arguments = "diff --exit-code" | ||
}, | ||
Process.Echo.Off | ||
) | ||
.UnwrapDefault() | ||
|> ignore |