Skip to content

Commit

Permalink
Fix reading env vars for JS and WASM JS (only NodeJS) (#335)
Browse files Browse the repository at this point in the history
While working on
#332, I found out
that the implementations for JS and WASM JS are missing. This PR focuses
on adding them. I don't want to add these in the PR that is related
solely to kotlinizing and commonizing the tests to give this fix a
proper visibility in the release notes.

This change was tested within
#332, and the goal
is to merge that PR soon after this one lands.

Note: env vars work only in a non-browser environment.
  • Loading branch information
krzema12 authored Jan 7, 2025
1 parent f9c0933 commit 5b8059f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
package it.krzeminski.snakeyaml.engine.kmp.internal

internal actual fun getEnvironmentVariable(key: String): String? {
return process.env[key] as String?
}

private external val process: Process

private external interface Process {
val env: dynamic
}

//region Identity hash code
// https://github.com/korlibs/korge/blob/60af53460dd2d68b6ac86cf459d82434e74be629/kds/src/jsMain/kotlin/korlibs/datastructure/internal/InternalJs.kt
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package it.krzeminski.snakeyaml.engine.kmp.internal

internal actual fun getEnvironmentVariable(key: String): String? {
js("return process.env[key]")
}

//region Identity hash code
internal actual fun objectIdentityHashCode(any: Any): IdentityHashCode {
val ref = any.toJsReference()
Expand Down

0 comments on commit 5b8059f

Please sign in to comment.