Skip to content
This repository was archived by the owner on Jul 30, 2024. It is now read-only.

Implement Process.features #182

Merged
merged 1 commit into from
Feb 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions app/current/src/main/scala/io/scalajs/nodejs/process/Process.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import io.scalajs.nodejs.events.IEventEmitter
import io.scalajs.nodejs.tty.{ReadStream, WriteStream}

import scala.scalajs.js
import scala.scalajs.js.annotation.JSGlobal
import scala.scalajs.js.annotation.{JSBracketAccess, JSGlobal}
import scala.scalajs.js.|

/**
Expand Down Expand Up @@ -82,10 +82,7 @@ trait Process extends IEventEmitter {
*/
def exitCode: Int = js.native

/**
* TODO find documentation for this property
*/
def features: js.Dictionary[Boolean] = js.native
def features: Features = js.native

/**
* Alternate way to retrieve require.main. The difference is that if the main module changes at runtime,
Expand Down Expand Up @@ -481,3 +478,24 @@ trait ResourceUsage extends js.Object {
var voluntaryContextSwitches: Int = js.native
var involuntaryContextSwitches: Int = js.native
}

@js.native
trait Features extends js.Object {
@deprecated("Use named members", "v0.10.0")
@JSBracketAccess
def apply(key: String): Boolean = js.native

val debug: Boolean = js.native
val uv: Boolean = js.native
val ipv6: Boolean = js.native
val tls_alpn: Boolean = js.native
val tls_sni: Boolean = js.native
val tls_ocsp: Boolean = js.native
val tls: Boolean = js.native

@enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12)
val inspector: Boolean = js.native

@enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12)
val cached_builtins: Boolean = js.native
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ProcessTest extends AnyFunSpec {
assert(Process.env.PATH === Process.env("PATH"))
assert(Process.execArgv.length === 0)
assert(Process.execPath.endsWith("node"))
assert(Process.features.contains("debug"))
assert(Process.features.uv)
assert(Process.moduleLoadList.length > 0)
assert(Process.title.isInstanceOf[String])
assert(Process.version.startsWith(versionPrefix))
Expand Down