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

Separate projects (Node.js v14, v12 and v10) #244

Merged
merged 5 commits into from
May 29, 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
2 changes: 1 addition & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- uses: actions/checkout@v1
- uses: olafurpg/setup-scala@v5
- name: Check Scalafmt/Scaladoc
run: sbt ++2.13.2 scalafmtSbtCheck scalafmtCheck test:scalafmtCheck current/doc core/doc
run: sbt ++2.13.2 scalafmtSbtCheck scalafmtCheck test:scalafmtCheck nodejs_v14/doc core/doc
- name: Install NPM deps
run: npm install
- name: Check README
Expand Down
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v12.16.1
v14.3.0
10 changes: 8 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@ jdk:

env:
matrix:
- TRAVIS_NODE_VERSION="12.16.3" SCALAJS_VERSION="0.6.33"
- TRAVIS_NODE_VERSION="12.16.3" SCALAJS_VERSION=""
- TRAVIS_NODE_VERSION="14.3.0" SCALAJS_VERSION="0.6.33"
- TRAVIS_NODE_VERSION="14.3.0" SCALAJS_VERSION=""

script:
- sbt ++$TRAVIS_SCALA_VERSION test

jobs:
include:
- name: "Node.12 Scala.js 0.6"
env: TRAVIS_NODE_VERSION="12.16.3" SCALAJS_VERSION="0.6.33"
script: sbt ++$TRAVIS_SCALA_VERSION nodejs_v12/test nodejs_v10/test
- name: "Node.12 Scala.js 1.x"
env: TRAVIS_NODE_VERSION="12.16.3" SCALAJS_VERSION=""
script: sbt ++$TRAVIS_SCALA_VERSION nodejs_v12/test nodejs_v10/test
- name: "Node.10 Scala.js 0.6"
env: TRAVIS_NODE_VERSION="10.20.1" SCALAJS_VERSION="0.6.33"
script: sbt ++$TRAVIS_SCALA_VERSION nodejs_v10/test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ object TestEnvironment {

def isWindows: Boolean = os.OS.platform().startsWith("win")

def isExecutedInExactNode14: Boolean = nodeMajorVersion == 14
def isExecutedInExactNode12: Boolean = nodeMajorVersion == 12
def isExecutedInExactNode10: Boolean = nodeMajorVersion == 10
def isExecutedInExactNode8: Boolean = nodeMajorVersion == 8

def isExecutedInNode14OrNewer: Boolean = nodeMajorVersion >= 14
def isExecutedInNode12OrNewer: Boolean = nodeMajorVersion >= 12
def isExecutedInNode10OrNewer: Boolean = nodeMajorVersion >= 10
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class ConsoleV8Test extends AnyFunSpec with BeforeAndAfterEach {

it("should support ignoreErrors") {
assume(TestEnvironment.isExecutedInNode10OrNewer)
// https://github.com/nodejs/node/issues/33628
assume(TestEnvironment.isExecutedInNode14OrNewer === false)
val strictConsole = new Console(
stdout = failingWritable,
stderr = failingWritable,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import org.scalatest.funspec.AsyncFunSpec
class FsTest extends AsyncFunSpec {
override implicit val executionContext = ExecutionContext.Implicits.global

final val testResources = "./app/current/src/test/resources/"
final val testResources = "./app/nodejs-v12/src/test/resources/"

describe("Fs") {
it("supports watching files") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class ProcessTest extends AnyFunSpec {
if (TestEnvironment.isExecutedInExactNode8) "v8."
else if (TestEnvironment.isExecutedInExactNode10) "v10."
else if (TestEnvironment.isExecutedInExactNode12) "v12."
else if (TestEnvironment.isExecutedInExactNode14) "v14."
else "Unknown node.js version"

it("contains the following properties") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ package object buffer {
@JSImport("buffer", JSImport.Namespace)
private object BufferNamespace extends js.Object {
val INSPECT_MAX_BYTES: Int = js.native
val kMaxLength: Int = js.native
val kMaxLength: Double = js.native
def transcode(source: Uint8Array, fromEnc: String, toEnc: String): Buffer = js.native
}

Expand All @@ -99,7 +99,7 @@ package object buffer {
* On 32-bit architectures, this value is `(2^30)-1` (~1GB).
* On 64-bit architectures, this value is `(2^31)-1` (~2GB).
*/
val MAX_LENGTH: Int = js.native
val MAX_LENGTH: Double = js.native

/**
* The largest length allowed for a single `String` instance.
Expand Down
33 changes: 27 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
organization in ThisBuild := "net.exoego"

lazy val root = (project in file("."))
.aggregate(core, current, nodejs_v10)
.aggregate(core, nodejs_v14, nodejs_v12, nodejs_v10)
.settings(MySettings.commonSettings)
.settings(MySettings.publishingSettings)
.settings(MySettings.nonPublishingSetting)
Expand All @@ -19,15 +19,36 @@ lazy val core = (project in file("./core"))
libraryDependencies ++= Dependencies.core.value
)

lazy val current = (project in file("./app/current"))
lazy val nodejs_v14 = (project in file("./app/nodejs-v14"))
.enablePlugins(ScalaJSPlugin)
.settings(MySettings.commonSettings)
.settings(MySettings.commonScalaJsSettings)
.settings(MySettings.commonMacroParadiseSetting)
.settings(MySettings.publishingSettings)
.settings(
scalacOptions ++= Seq(
"-Xmacro-settings:nodeJs12.5.0"
"-Xmacro-settings:nodeJs14.3.0"
),
name := "scala-js-nodejs-v14",
description := "NodeJS v14 API for Scala.js",
libraryDependencies ++= Dependencies.app.value
)
.dependsOn(core)

lazy val nodejs_v12 = (project in file("./app/nodejs-v12"))
.enablePlugins(ScalaJSPlugin)
.settings(MySettings.commonSettings)
.settings(MySettings.commonScalaJsSettings)
.settings(MySettings.commonMacroParadiseSetting)
.settings(MySettings.publishingSettings)
.settings(
unmanagedSourceDirectories in Compile ++= {
val symlinkDir = baseDirectory.value / "src" / "main"
val hasSymlink = symlinkDir.exists && symlinkDir.isDirectory
Seq((baseDirectory in nodejs_v14).value / "src" / "main" / "scala").filter(_ => !hasSymlink)
},
scalacOptions ++= Seq(
"-Xmacro-settings:nodeJs12.16.3"
),
name := "scala-js-nodejs-v12",
description := "NodeJS v12 API for Scala.js",
Expand All @@ -45,13 +66,13 @@ lazy val nodejs_v10 = (project in file("./app/nodejs-v10"))
unmanagedSourceDirectories in Compile ++= {
val symlinkDir = baseDirectory.value / "src" / "main"
val hasSymlink = symlinkDir.exists && symlinkDir.isDirectory
Seq((baseDirectory in current).value / "src" / "main" / "scala").filter(_ => !hasSymlink)
Seq((baseDirectory in nodejs_v14).value / "src" / "main" / "scala").filter(_ => !hasSymlink)
},
scalacOptions ++= Seq(
"-Xmacro-settings:nodeJs10.16.0"
"-Xmacro-settings:nodeJs10.20.1"
),
name := "scala-js-nodejs-v10",
description := "NodeJS v10.16.0 API for Scala.js",
description := "NodeJS v10 API for Scala.js",
libraryDependencies ++= Dependencies.app.value
)
.dependsOn(core)
19 changes: 19 additions & 0 deletions script/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

SOURCE_DIR=$(pwd)/app/nodejs-v14/src/main

V12_DIR=$(pwd)/app/nodejs-v12/src/main
if [ -e "$V12_DIR" ]; then
echo "V12 dir already exists."
else
ln -s "$SOURCE_DIR" "$V12_DIR";
echo "V12 dir created.";
fi

V10_DIR=$(pwd)/app/nodejs-v10/src/main
if [ -e "$V10_DIR" ]; then
echo "V10 dir already exists."
else
ln -s "$SOURCE_DIR" "$V10_DIR";
echo "V1 dir created.";
fi