Skip to content

Commit

Permalink
Merge pull request #88 from ephemient/kt/js
Browse files Browse the repository at this point in the history
  • Loading branch information
ephemient authored Dec 11, 2024
2 parents d5f3881 + c211c8f commit a3ed5a8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ package com.github.ephemient.aoc2024.exe
import com.github.ephemient.aoc2024.days

internal suspend fun mainImpl(args: Array<out String>) {
for (day in days) {
if ((args.isNotEmpty() || day.skipByDefault) && day.name !in args) continue
for (day in days.filter { it.name in args }.ifEmpty { days }) {
println("Day ${day.name}")
for (part in day.solver(getDayInput(day.day))) println(part())
println()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package com.github.ephemient.aoc2024.exe
import js.globals.globalThis

suspend fun main() {
mainImpl(with(globalThis.asDynamic().process.argv.unsafeCast<Array<String>>()) { copyOfRange(2, size) })
mainImpl(globalThis.asDynamic().process.argv.unsafeCast<Array<String>>())
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.github.ephemient.aoc2024.exe

private fun argv(): JsArray<JsString> = js("process.argv")
@JsModule("node:process")
private external val argv: JsArray<JsString>

suspend fun main() {
val argv = argv()
mainImpl(Array(argv.length - 2) { argv[it + 2].toString() })
val argv = argv
mainImpl(Array(argv.length) { argv[it].toString() })
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.github.ephemient.aoc2024.exe

suspend fun main() {
val argv = argv()
mainImpl(argv.copyOfRange(2, argv.size))
mainImpl(argv())
}

0 comments on commit a3ed5a8

Please sign in to comment.