Skip to content

Commit

Permalink
Added script for Windows (#1859)
Browse files Browse the repository at this point in the history
- renamed unix script to header
- added script for Windows
- updated workflow to add Windows script as artifact
- fixed coloring in plain reporter
  • Loading branch information
nulls authored Dec 13, 2023
1 parent 73cd9a7 commit c20f2d5
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 9 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,18 @@ jobs:
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./diktat-cli/build/diktat-cli-${{ github.ref }}
asset_name: diktat-cli-${{ github.ref }}
asset_name: diktat
asset_content_type: application/zip
- name: Upload Diktat CLI for Windows to GitHub release
id: upload-release-asset-cli-win
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./diktat-cli/src/main/script/diktat.cmd
asset_name: diktat.cmd
asset_content_type: application/octet-stream
- name: Upload Diktat ruleset for KtLint to GitHub release
id: upload-release-asset-ruleset
uses: actions/upload-release-asset@v1
Expand Down
2 changes: 1 addition & 1 deletion diktat-cli/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ tasks.register<DefaultTask>("shadowExecutableJar") {
group = "Distribution"
dependsOn(tasks.shadowJar)

val scriptFile = project.file("src/main/script/diktat.sh")
val scriptFile = project.file("src/main/script/header-diktat.sh")
val shadowJarFile = tasks.shadowJar
.get()
.outputs
Expand Down
19 changes: 19 additions & 0 deletions diktat-cli/src/main/script/diktat.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@echo off

rem
rem diKTat command-line client for Windows
rem
rem Uses Git Bash, so requires Git to be installed.
rem

set "git_install_location=%ProgramFiles%\Git"
set "git_url=https://github.com/git-for-windows/git/releases/latest"

if exist "%git_install_location%" (
setlocal
set "PATH=%git_install_location%\usr\bin;%PATH%"
for /f "usebackq tokens=*" %%p in (`cygpath "%~dpn0"`) do bash --noprofile --norc %%p %*
) else (
echo Expecting Git for Windows at %git_install_location%; please install it from %git_url%
start %git_url%
)
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,8 @@ class DiktatReporterFactoryImpl : DiktatReporterFactory {
}
val opts = if (args is PlainDiktatReporterCreationArguments) {
buildMap<String, Any> {
args.colorName?.let {
put("color", true)
put("color_name", it)
} ?: run {
put("color", false)
put("color_name", Color.DARK_GRAY)
}
put("color", args.colorName?.let { true } ?: false)
put("color_name", args.colorName ?: Color.DARK_GRAY)
args.groupByFile?.let { put("group_by_file", it) }
}.mapValues { it.value.toString() }
} else if (args.reporterType == DiktatReporterType.PLAIN) {
Expand Down

0 comments on commit c20f2d5

Please sign in to comment.