Skip to content

Commit

Permalink
scripts/styleCheck: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
tehraninasab committed Aug 7, 2023
1 parent c185305 commit c7b0b00
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
13 changes: 13 additions & 0 deletions scripts/styleCheck.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,19 @@ let CheckStyleOfXamlFiles(rootDir: DirectoryInfo) : bool =

let rootDir = Path.Combine(__SOURCE_DIRECTORY__, "..") |> DirectoryInfo

// We need this step so we can change the files using `npx prettier --write` in the prettier calls.
// Otherwise we get permission denied error in the CI.
Process
.Execute(
{
Command = "chmod"
Arguments = "777 --recursive ."
},
Echo.Off
)
.UnwrapDefault()
|> ignore

let processSuccessStates =
[|
CheckStyleOfFSharpFiles rootDir
Expand Down
6 changes: 3 additions & 3 deletions src/FileConventions/Config.fs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Config

let fantomlessToolVersion = "4.7.997-prerelease"
let prettierVersion = "2.8.3"
let pluginXmlVersion = "v2.2.0"
let FantomlessToolVersion = "4.7.997-prerelease"
let PrettierVersion = "2.8.3"
let PluginXmlVersion = "v2.2.0"
13 changes: 0 additions & 13 deletions src/FileConventions/Helpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -212,19 +212,6 @@ let InstallPrettierPluginXml(version: string) =

let RunPrettier(arguments: string) =

// We need this step so we can change the files using `npx prettier --write` in the next step.
// Otherwise we get permission denied error in the CI.
Process
.Execute(
{
Command = "chmod"
Arguments = "777 --recursive ."
},
Echo.Off
)
.UnwrapDefault()
|> ignore

Process.Execute(
{
Command = "npx"
Expand Down
12 changes: 6 additions & 6 deletions src/FileConventions/Library.fs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ let NonVerboseFlags(fileInfo: FileInfo) =


let StyleFSharpFiles(rootDir: DirectoryInfo) =
InstallFantomlessTool fantomlessToolVersion
InstallFantomlessTool FantomlessToolVersion

Process
.Execute(
Expand All @@ -413,15 +413,15 @@ let StyleCSharpFiles(rootDir: DirectoryInfo) =
|> ignore

let StyleXamlFiles() =
InstallPrettier prettierVersion
InstallPrettierPluginXml pluginXmlVersion
InstallPrettier PrettierVersion
InstallPrettierPluginXml PluginXmlVersion

Process
.Execute(
{
Command = "npm"
Arguments =
$"install --save-dev prettier@{prettierVersion} @prettier/plugin-xml@{pluginXmlVersion}"
$"install --save-dev prettier@{PrettierVersion} @prettier/plugin-xml@{PluginXmlVersion}"
},
Echo.Off
)
Expand Down Expand Up @@ -450,15 +450,15 @@ let StyleXamlFiles() =
|> ignore

let StyleTypeScriptFiles() =
InstallPrettier prettierVersion
InstallPrettier PrettierVersion

let pattern =
$"{Directory.GetCurrentDirectory()}{Path.DirectorySeparatorChar}**{Path.DirectorySeparatorChar}*.ts"

RunPrettier $"--quote-props=consistent --write {pattern}"

let StyleYmlFiles() =
InstallPrettier prettierVersion
InstallPrettier PrettierVersion

let pattern =
$"{Directory.GetCurrentDirectory()}{Path.DirectorySeparatorChar}**{Path.DirectorySeparatorChar}*.yml"
Expand Down

0 comments on commit c7b0b00

Please sign in to comment.