Skip to content

Commit a236c71

Browse files
committed
Unify the parameter names of external JS env constructors.
They all standardize on `executable`, `args` en `env`, which are the names used by the `Initialize` constructors in `ScalaJSPlugin`.
1 parent ac662e6 commit a236c71

File tree

3 files changed

+43
-25
lines changed

3 files changed

+43
-25
lines changed

js-envs/src/main/scala/org/scalajs/jsenv/ExternalJSEnv.scala

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ import scala.concurrent.{Future, Promise}
1111
import scala.util.Try
1212

1313
abstract class ExternalJSEnv(
14-
final protected val additionalArgs: Seq[String],
15-
final protected val additionalEnv: Map[String, String]) extends AsyncJSEnv {
14+
@deprecatedName('additionalArgs)
15+
final protected val args: Seq[String],
16+
@deprecatedName('additionalEnv)
17+
final protected val env: Map[String, String])
18+
extends AsyncJSEnv {
1619

1720
import ExternalJSEnv._
1821

@@ -24,6 +27,12 @@ abstract class ExternalJSEnv(
2427
/** Command to execute (on shell) for this VM */
2528
protected def executable: String
2629

30+
@deprecated("Use `args` instead.", "0.6.16")
31+
final protected def additionalArgs: Seq[String] = args
32+
33+
@deprecated("Use `env` instead.", "0.6.16")
34+
final protected def additionalEnv: Map[String, String] = env
35+
2736
/** Custom initialization scripts. */
2837
protected def customInitFiles(): Seq[VirtualJSFile] = Nil
2938

@@ -51,16 +60,17 @@ abstract class ExternalJSEnv(
5160
protected def sendVMStdin(out: OutputStream): Unit = {}
5261

5362
/** VM arguments excluding executable. Override to adapt.
54-
* Overrider is responsible to add additionalArgs.
63+
*
64+
* The default value in `ExternalJSEnv` is `args`.
5565
*/
56-
protected def getVMArgs(): Seq[String] = additionalArgs
66+
protected def getVMArgs(): Seq[String] = args
5767

5868
/** VM environment. Override to adapt.
5969
*
60-
* Default is `sys.env` and [[additionalEnv]]
70+
* The default value in `ExternalJSEnv` is `sys.env ++ env`.
6171
*/
6272
protected def getVMEnv(): Map[String, String] =
63-
sys.env ++ additionalEnv
73+
sys.env ++ env
6474

6575
/** Get files that are a library (i.e. that do not run anything) */
6676
protected def getLibJSFiles(): Seq[VirtualJSFile] =

js-envs/src/main/scala/org/scalajs/jsenv/nodejs/AbstractNodeJSEnv.scala

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,15 @@ import org.scalajs.jsenv.Utils.OptDeadline
2222
import scala.concurrent.TimeoutException
2323
import scala.concurrent.duration._
2424

25-
abstract class AbstractNodeJSEnv(nodejsPath: String, addArgs: Seq[String],
26-
addEnv: Map[String, String], val sourceMap: Boolean)
27-
extends ExternalJSEnv(addArgs, addEnv) with ComJSEnv {
25+
abstract class AbstractNodeJSEnv(
26+
@deprecatedName('nodejsPath)
27+
protected val executable: String,
28+
@deprecatedName('addArgs)
29+
args: Seq[String],
30+
@deprecatedName('addEnv)
31+
env: Map[String, String],
32+
val sourceMap: Boolean)
33+
extends ExternalJSEnv(args, env) with ComJSEnv {
2834

2935
/** True, if the installed node executable supports source mapping.
3036
*
@@ -43,8 +49,6 @@ abstract class AbstractNodeJSEnv(nodejsPath: String, addArgs: Seq[String],
4349
}
4450
}
4551

46-
protected def executable: String = nodejsPath
47-
4852
/** Retry-timeout to wait for the JS VM to connect */
4953
protected val acceptTimeout = 5000
5054

js-envs/src/main/scala/org/scalajs/jsenv/nodejs/NodeJSEnv.scala

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,31 @@ import org.scalajs.core.tools.logging._
1919

2020
import java.io.{ Console => _, _ }
2121

22-
2322
class NodeJSEnv private (
24-
nodejsPath: String,
25-
addArgs: Seq[String],
26-
addEnv: Map[String, String],
27-
sourceMap: Boolean
28-
) extends AbstractNodeJSEnv(nodejsPath, addArgs, addEnv, sourceMap) {
29-
30-
def this(nodejsPath: String = "node", addArgs: Seq[String] = Seq.empty,
31-
addEnv: Map[String, String] = Map.empty) = {
32-
this(nodejsPath, addArgs, addEnv, sourceMap = true)
23+
@deprecatedName('nodejsPath)
24+
override protected val executable: String, // override val for bin compat
25+
@deprecatedName('addArgs)
26+
args: Seq[String],
27+
@deprecatedName('addEnv)
28+
env: Map[String, String],
29+
sourceMap: Boolean)
30+
extends AbstractNodeJSEnv(executable, args, env, sourceMap) {
31+
32+
def this(
33+
@deprecatedName('nodejsPath)
34+
executable: String = "node",
35+
@deprecatedName('addArgs)
36+
args: Seq[String] = Seq.empty,
37+
@deprecatedName('addEnv)
38+
env: Map[String, String] = Map.empty) = {
39+
this(executable, args, env, sourceMap = true)
3340
}
3441

3542
def withSourceMap(sourceMap: Boolean): NodeJSEnv =
36-
new NodeJSEnv(nodejsPath, addArgs, addEnv, sourceMap)
43+
new NodeJSEnv(executable, args, env, sourceMap)
3744

3845
protected def vmName: String = "Node.js"
3946

40-
// For binary compatibility, now `executable` is defined in AbstractNodeJSEnv
41-
override protected def executable: String = super.executable
42-
4347
override def jsRunner(libs: Seq[ResolvedJSDependency],
4448
code: VirtualJSFile): JSRunner = {
4549
new NodeRunner(libs, code)

0 commit comments

Comments
 (0)