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

Commit 977a40c

Browse files
author
exoego
committed
Implement Process.features
1 parent 341732e commit 977a40c

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

app/current/src/main/scala/io/scalajs/nodejs/process/Process.scala

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import io.scalajs.nodejs.events.IEventEmitter
55
import io.scalajs.nodejs.tty.{ReadStream, WriteStream}
66

77
import scala.scalajs.js
8-
import scala.scalajs.js.annotation.JSGlobal
8+
import scala.scalajs.js.annotation.{JSBracketAccess, JSGlobal}
99
import scala.scalajs.js.|
1010

1111
/**
@@ -82,10 +82,7 @@ trait Process extends IEventEmitter {
8282
*/
8383
def exitCode: Int = js.native
8484

85-
/**
86-
* TODO find documentation for this property
87-
*/
88-
def features: js.Dictionary[Boolean] = js.native
85+
def features: Features = js.native
8986

9087
/**
9188
* Alternate way to retrieve require.main. The difference is that if the main module changes at runtime,
@@ -481,3 +478,24 @@ trait ResourceUsage extends js.Object {
481478
var voluntaryContextSwitches: Int = js.native
482479
var involuntaryContextSwitches: Int = js.native
483480
}
481+
482+
@js.native
483+
trait Features extends js.Object {
484+
@deprecated("Use named members", "v0.10.0")
485+
@JSBracketAccess
486+
def apply(key: String): Boolean = js.native
487+
488+
val debug: Boolean = js.native
489+
val uv: Boolean = js.native
490+
val ipv6: Boolean = js.native
491+
val tls_alpn: Boolean = js.native
492+
val tls_sni: Boolean = js.native
493+
val tls_ocsp: Boolean = js.native
494+
val tls: Boolean = js.native
495+
496+
@enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12)
497+
val inspector: Boolean = js.native
498+
499+
@enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12)
500+
val cached_builtins: Boolean = js.native
501+
}

app/nodejs-v10/src/test/scala/io/scalajs/nodejs/process/ProcessTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class ProcessTest extends AnyFunSpec {
2323
assert(Process.env.PATH === Process.env("PATH"))
2424
assert(Process.execArgv.length === 0)
2525
assert(Process.execPath.endsWith("node"))
26-
assert(Process.features.contains("debug"))
26+
assert(Process.features.uv)
2727
assert(Process.moduleLoadList.length > 0)
2828
assert(Process.title.isInstanceOf[String])
2929
assert(Process.version.startsWith(versionPrefix))

0 commit comments

Comments
 (0)