Skip to content

Commit 26151cb

Browse files
committed
fix(apiDocs): npm and npx command execution fixed
1 parent b00d95e commit 26151cb

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

plugin/src/main/kotlin/hu.vanio.gradle.apiDocs.gradle.kts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,29 @@ tasks.create("generateDocs") {
2222
} ?: throw RuntimeException("Function 'groupedApiMappings' not found.")
2323
val outputFileName = openApiExt::class.members.firstOrNull {
2424
it.name == "outputFileName"
25-
} ?: throw RuntimeException("Founction 'outputFileName' not found.")
25+
} ?: throw RuntimeException("Function 'outputFileName' not found.")
2626
var docList = (groupedApiMappings.call(openApiExt) as MapProperty<String, String>).get().map { it.value }
2727
if (docList.isEmpty()) {
2828
docList = listOf((outputFileName.call(openApiExt) as Property<String>).get())
2929
}
3030
exec {
3131
workingDir("$buildDir")
32-
commandLine(if (Os.isFamily(Os.FAMILY_WINDOWS)) "npm.cmd" else "npm", "i", "-g", "redoc-cli")
32+
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
33+
commandLine("npm.cmd", "i", "-g", "redoc-cli")
34+
} else {
35+
commandLine("bash", "-lc", "npm i -g redoc-cli")
36+
}
3337
}
3438
docList.forEach { docnameTeljes ->
3539
val docname = docnameTeljes.removeSuffix(".json")
3640
println("doc: $docname")
3741
exec {
3842
workingDir(outputDirString)
39-
commandLine(
40-
if (Os.isFamily(Os.FAMILY_WINDOWS)) "npx.cmd" else "npx",
41-
"redoc-cli",
42-
"build",
43-
"$docname.json"
44-
)
43+
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
44+
commandLine("npx.cmd", "redoc-cli", "build", "$docname.json")
45+
} else {
46+
commandLine("bash", "-lc", "npx redoc-cli build $docname.json")
47+
}
4548
}
4649
copy {
4750
from(outputDirString)

0 commit comments

Comments
 (0)