Skip to content

Commit

Permalink
fix(ci): windows stuffs
Browse files Browse the repository at this point in the history
  • Loading branch information
manuandru committed Mar 15, 2024
1 parent 1fdcc52 commit 417cc58
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
9 changes: 0 additions & 9 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ on:
workflow_call:
workflow_dispatch:

defaults:
run:
shell: bash

jobs:
build:
strategy:
Expand All @@ -20,11 +16,6 @@ jobs:
steps:
- name: Checkout
uses: DanySK/action-checkout@0.2.14
- uses: actions/setup-node@v4
if: matrix.os == 'windows-2022'
with:
node-version: 18
cache: 'npm'
- uses: DanySK/build-check-deploy-gradle-action@2.4.8
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ import com.lordcodes.turtle.ShellScript
*/
object NpmCommandsExtension {

private fun String.cmdIfOnWindows(): String = System.getProperty("os.name").let { os ->
when {
os.contains("Windows") -> "$this.cmd"
else -> this
}
}

private val npmCommand: String = "npm".cmdIfOnWindows()
private val npxCommand: String = "npx".cmdIfOnWindows()

/**
* Install the dependencies.
*/
Expand All @@ -15,10 +25,10 @@ object NpmCommandsExtension {
/**
* Run the NPM command.
*/
fun ShellScript.npmCommand(vararg arguments: String): String = command("npm", arguments.toList())
fun ShellScript.npmCommand(vararg arguments: String): String = command(npmCommand, arguments.toList())

/**
* Run the NPX command.
*/
fun ShellScript.npxCommand(vararg arguments: String): String = command("npx", arguments.toList())
fun ShellScript.npxCommand(vararg arguments: String): String = command(npxCommand, arguments.toList())
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,19 @@ class TypescriptPluginTest : AnnotationSpec() {
build()
}

private fun Path.stringWalk(): List<String> = toFile().walk().map { it.relativeTo(toFile()).toString() }.toList()
private fun Path.walkRelative(): List<File> = toFile().walk().map { it.relativeTo(toFile()) }.toList()

@Test
fun `test base configuration`() {
val testFolder = getTempDirectoryWithResources()
testFolder.executeGradleTask("compileTypescript", "--stacktrace")

testFolder.stringWalk() shouldContainAll listOf(
testFolder.walkRelative() shouldContainAll listOf(
"build/dist",
"build/dist/index.js",
"build/dist/person.js",
"node_modules",
"package-lock.json",
)
).map { File(it) }
}
}

0 comments on commit 417cc58

Please sign in to comment.