From c38541d60db0a1a479bb932ce457f1831c49c319 Mon Sep 17 00:00:00 2001 From: exoego Date: Thu, 2 Jan 2020 09:25:54 +0900 Subject: [PATCH 1/4] Merge Node.js v8 tests into Node.js v10 sub project --- .../scala/io/scalajs/nodejs/AssertTest.scala | 0 .../io/scalajs/nodejs/StringDecoderTest.scala | 0 .../io/scalajs/nodejs/TestEnvironment.scala | 0 .../io/scalajs/nodejs/buffer/BufferTest.scala | 0 .../child_process/ChildProcessTest.scala | 0 .../scalajs/nodejs/cluster/ClusterTest.scala | 0 .../console_module/ConsoleV8Test.scala} | 2 +- .../nodejs/crypto/CertificateTest.scala | 25 +++++ .../io/scalajs/nodejs/crypto/CryptoTest.scala | 50 ++++++++++ .../io/scalajs/nodejs/dns/DNSAsyncTest.scala | 86 +++++++++++++++- .../nodejs/events/EventEmitterTest.scala | 0 .../scala/io/scalajs/nodejs/fs/FsTest.scala | 0 .../io/scalajs/nodejs/fs/FsV8AsyncTest.scala} | 2 +- .../io/scalajs/nodejs/fs/ReadStreamTest.scala | 0 .../io/scalajs/nodejs/http/HttpTest.scala | 0 .../scalajs/nodejs/http/StatusCodeTest.scala | 0 .../nodejs/http2/Http2HeadersTest.scala | 0 .../scala/io/scalajs/nodejs/net/NetTest.scala | 0 .../scala/io/scalajs/nodejs/os/OSTest.scala | 0 .../io/scalajs/nodejs/path/PathTest.scala | 30 ++++++ .../nodejs/process/EnvironmentTest.scala | 0 .../scalajs/nodejs/process/ProcessTest.scala | 38 ++++++++ .../nodejs/querystring/QueryStringTest.scala | 0 .../nodejs/readline/ReadlineTest.scala | 0 .../scala/io/scalajs/nodejs/tty/TTYTest.scala | 0 .../io/scalajs/nodejs/url/URLObjectTest.scala | 0 .../nodejs/url/URLSearchParamsTest.scala | 0 .../scala/io/scalajs/nodejs/url/URLTest.scala | 0 .../io/scalajs/nodejs/util/UtilTest.scala | 22 +++++ .../scala/io/scalajs/nodejs/vm/VMTest.scala | 0 .../io/scalajs/nodejs/zlib/ZlibTest.scala | 0 .../nodejs/crypto/CertificateTest.scala | 34 ------- .../io/scalajs/nodejs/crypto/CryptoTest.scala | 58 ----------- .../io/scalajs/nodejs/dns/DNSAsyncTest.scala | 97 ------------------- .../io/scalajs/nodejs/path/PathTest.scala | 40 -------- .../scalajs/nodejs/process/ProcessTest.scala | 45 --------- .../io/scalajs/nodejs/util/UtilTest.scala | 29 ------ 37 files changed, 252 insertions(+), 306 deletions(-) rename app/{nodejs-v8 => nodejs-v10}/src/test/scala/io/scalajs/nodejs/AssertTest.scala (100%) rename app/{nodejs-v8 => nodejs-v10}/src/test/scala/io/scalajs/nodejs/StringDecoderTest.scala (100%) rename app/{nodejs-v8 => nodejs-v10}/src/test/scala/io/scalajs/nodejs/TestEnvironment.scala (100%) rename app/{nodejs-v8 => nodejs-v10}/src/test/scala/io/scalajs/nodejs/buffer/BufferTest.scala (100%) rename app/{nodejs-v8 => nodejs-v10}/src/test/scala/io/scalajs/nodejs/child_process/ChildProcessTest.scala (100%) rename app/{nodejs-v8 => nodejs-v10}/src/test/scala/io/scalajs/nodejs/cluster/ClusterTest.scala (100%) rename app/{nodejs-v8/src/test/scala/io/scalajs/nodejs/console_module/ConsoleTest.scala => nodejs-v10/src/test/scala/io/scalajs/nodejs/console_module/ConsoleV8Test.scala} (95%) rename app/{nodejs-v8 => nodejs-v10}/src/test/scala/io/scalajs/nodejs/events/EventEmitterTest.scala (100%) rename app/{nodejs-v8 => nodejs-v10}/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala (100%) rename app/{nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/FsAsyncTest.scala => nodejs-v10/src/test/scala/io/scalajs/nodejs/fs/FsV8AsyncTest.scala} (97%) rename app/{nodejs-v8 => nodejs-v10}/src/test/scala/io/scalajs/nodejs/fs/ReadStreamTest.scala (100%) rename app/{nodejs-v8 => nodejs-v10}/src/test/scala/io/scalajs/nodejs/http/HttpTest.scala (100%) rename app/{nodejs-v8 => nodejs-v10}/src/test/scala/io/scalajs/nodejs/http/StatusCodeTest.scala (100%) rename app/{nodejs-v8 => nodejs-v10}/src/test/scala/io/scalajs/nodejs/http2/Http2HeadersTest.scala (100%) rename app/{nodejs-v8 => nodejs-v10}/src/test/scala/io/scalajs/nodejs/net/NetTest.scala (100%) rename app/{nodejs-v8 => nodejs-v10}/src/test/scala/io/scalajs/nodejs/os/OSTest.scala (100%) rename app/{nodejs-v8 => nodejs-v10}/src/test/scala/io/scalajs/nodejs/process/EnvironmentTest.scala (100%) rename app/{nodejs-v8 => nodejs-v10}/src/test/scala/io/scalajs/nodejs/querystring/QueryStringTest.scala (100%) rename app/{nodejs-v8 => nodejs-v10}/src/test/scala/io/scalajs/nodejs/readline/ReadlineTest.scala (100%) rename app/{nodejs-v8 => nodejs-v10}/src/test/scala/io/scalajs/nodejs/tty/TTYTest.scala (100%) rename app/{nodejs-v8 => nodejs-v10}/src/test/scala/io/scalajs/nodejs/url/URLObjectTest.scala (100%) rename app/{nodejs-v8 => nodejs-v10}/src/test/scala/io/scalajs/nodejs/url/URLSearchParamsTest.scala (100%) rename app/{nodejs-v8 => nodejs-v10}/src/test/scala/io/scalajs/nodejs/url/URLTest.scala (100%) rename app/{nodejs-v8 => nodejs-v10}/src/test/scala/io/scalajs/nodejs/vm/VMTest.scala (100%) rename app/{nodejs-v8 => nodejs-v10}/src/test/scala/io/scalajs/nodejs/zlib/ZlibTest.scala (100%) delete mode 100644 app/nodejs-v8/src/test/scala/io/scalajs/nodejs/crypto/CertificateTest.scala delete mode 100644 app/nodejs-v8/src/test/scala/io/scalajs/nodejs/crypto/CryptoTest.scala delete mode 100644 app/nodejs-v8/src/test/scala/io/scalajs/nodejs/dns/DNSAsyncTest.scala delete mode 100644 app/nodejs-v8/src/test/scala/io/scalajs/nodejs/path/PathTest.scala delete mode 100644 app/nodejs-v8/src/test/scala/io/scalajs/nodejs/process/ProcessTest.scala delete mode 100644 app/nodejs-v8/src/test/scala/io/scalajs/nodejs/util/UtilTest.scala diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/AssertTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/AssertTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/io/scalajs/nodejs/AssertTest.scala rename to app/nodejs-v10/src/test/scala/io/scalajs/nodejs/AssertTest.scala diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/StringDecoderTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/StringDecoderTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/io/scalajs/nodejs/StringDecoderTest.scala rename to app/nodejs-v10/src/test/scala/io/scalajs/nodejs/StringDecoderTest.scala diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/TestEnvironment.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/TestEnvironment.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/io/scalajs/nodejs/TestEnvironment.scala rename to app/nodejs-v10/src/test/scala/io/scalajs/nodejs/TestEnvironment.scala diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/buffer/BufferTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/buffer/BufferTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/io/scalajs/nodejs/buffer/BufferTest.scala rename to app/nodejs-v10/src/test/scala/io/scalajs/nodejs/buffer/BufferTest.scala diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/child_process/ChildProcessTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/child_process/ChildProcessTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/io/scalajs/nodejs/child_process/ChildProcessTest.scala rename to app/nodejs-v10/src/test/scala/io/scalajs/nodejs/child_process/ChildProcessTest.scala diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/cluster/ClusterTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/cluster/ClusterTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/io/scalajs/nodejs/cluster/ClusterTest.scala rename to app/nodejs-v10/src/test/scala/io/scalajs/nodejs/cluster/ClusterTest.scala diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/console_module/ConsoleTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/console_module/ConsoleV8Test.scala similarity index 95% rename from app/nodejs-v8/src/test/scala/io/scalajs/nodejs/console_module/ConsoleTest.scala rename to app/nodejs-v10/src/test/scala/io/scalajs/nodejs/console_module/ConsoleV8Test.scala index 9d5280c83..a9c04d846 100644 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/console_module/ConsoleTest.scala +++ b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/console_module/ConsoleV8Test.scala @@ -6,7 +6,7 @@ import org.scalatest.{BeforeAndAfterEach, FunSpec} import scala.scalajs.js.JavaScriptException -class ConsoleTest extends FunSpec with BeforeAndAfterEach { +class ConsoleV8Test extends FunSpec with BeforeAndAfterEach { private val logFileName = "x.nodejs8.ConsoleTest" private var failingWritable: WriteStream = null diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/crypto/CertificateTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/crypto/CertificateTest.scala index c0ff83685..6aec417fc 100644 --- a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/crypto/CertificateTest.scala +++ b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/crypto/CertificateTest.scala @@ -7,6 +7,31 @@ class CertificateTest extends FunSpec with MustMatchers { val spkacExample = "MIIBXjCByDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA3L0IfUijj7+A8CPC8EmhcdNoe5fUAog7OrBdhn7EkxFButUp40P7+LiYiygYG1TmoI/a5EgsLU3s9twEz3hmgY9mYIqb/rb+SF8qlD/K6KVyUORC7Wlz1Df4L8O3DuRGzx6/+3jIW6cPBpfgH1sVuYS1vDBsP/gMMIxwTsKJ4P0CAwEAARYkYzBkZjFlYjctMTU0NC00MWVkLWFmN2EtZDRkYjBkNDc5ZjZmMA0GCSqGSIb3DQEBBAUAA4GBALEiapUjaIPs5uEdvCP0gFK2qofo+4GpeK1A43mu28lirYPAvCWsmYvKIZIT9TxvzmQIxAfxobf70aSNlSm6MJJKmvurAK+Bpn6ZUKQZ6A1m927LvctVSYJuUi+WVmr0fGE/OfdQ+BqSm/eQ3jnm3fBPVx1uwLPgjC5g4EvGMh8M" + describe("Certificate class (Legacy)") { + val instance = new Certificate() + + it("exportChallenge") { + assert(instance.exportChallenge(spkacExample).toString("utf8") === "c0df1eb7-1544-41ed-af7a-d4db0d479f6f") + } + + it("exportPublicKey") { + assert( + instance.exportPublicKey(spkacExample).toString("utf8") === + """-----BEGIN PUBLIC KEY----- + |MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDcvQh9SKOPv4DwI8LwSaFx02h7 + |l9QCiDs6sF2GfsSTEUG61SnjQ/v4uJiLKBgbVOagj9rkSCwtTez23ATPeGaBj2Zg + |ipv+tv5IXyqUP8ropXJQ5ELtaXPUN/gvw7cO5EbPHr/7eMhbpw8Gl+AfWxW5hLW8 + |MGw/+AwwjHBOwong/QIDAQAB + |-----END PUBLIC KEY----- + |""".stripMargin + ) + } + + it("verifySpkac") { + assert(instance.verifySpkac(Buffer.from("foo")) === false) + } + } + describe("Certificate object") { it("exportChallenge") { assert(Certificate.exportChallenge(spkacExample).toString("utf8") === "c0df1eb7-1544-41ed-af7a-d4db0d479f6f") diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/crypto/CryptoTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/crypto/CryptoTest.scala index d7bdfe5a6..3652b4de7 100644 --- a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/crypto/CryptoTest.scala +++ b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/crypto/CryptoTest.scala @@ -10,6 +10,56 @@ class CryptoTest extends FunSpec with MustMatchers { val spkacExample = "MIIBXjCByDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA3L0IfUijj7+A8CPC8EmhcdNoe5fUAog7OrBdhn7EkxFButUp40P7+LiYiygYG1TmoI/a5EgsLU3s9twEz3hmgY9mYIqb/rb+SF8qlD/K6KVyUORC7Wlz1Df4L8O3DuRGzx6/+3jIW6cPBpfgH1sVuYS1vDBsP/gMMIxwTsKJ4P0CAwEAARYkYzBkZjFlYjctMTU0NC00MWVkLWFmN2EtZDRkYjBkNDc5ZjZmMA0GCSqGSIb3DQEBBAUAA4GBALEiapUjaIPs5uEdvCP0gFK2qofo+4GpeK1A43mu28lirYPAvCWsmYvKIZIT9TxvzmQIxAfxobf70aSNlSm6MJJKmvurAK+Bpn6ZUKQZ6A1m927LvctVSYJuUi+WVmr0fGE/OfdQ+BqSm/eQ3jnm3fBPVx1uwLPgjC5g4EvGMh8M" + describe("Crypto") { + val text = "Hello World" + + it("should be able to create an MD5 hash from a string") { + val hasher = Crypto.createHash("md5") + hasher.update(text) + val buffer = hasher.digest() + assert(buffer.toHexString === "b10a8db164e0754105b7a99be72e3fe5") + } + + it("should be able to create a SHA256 hash from a string") { + val hasher = Crypto.createHash("sha256") + hasher.update(text) + val buffer = hasher.digest() + assert(buffer.toHexString === "a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e") + } + + it("should be able to hash passwords with pbkdf2Sync") { + val computedHash = + Crypto.pbkdf2Sync("this-is-a-password", "random-salt", 10000, 512, "sha512").toString("base64") + val expectedHash = + "nzaxkuDuglFxKDMtr566d1mlr7kZV5y1j5PWpU9E/R9cpZz5q8pyYgeuTWADj2DhBF6koAsikPOac81lOHgK+tgiIYy6YRBd0SylsewT3QR5CelagTY1nrKougkJi95TmyKplJIO9M2szDqMhX5eT0yY2eVLnv9R0SCjd3qunvbVJmOvfEOgetPCwu5oUfRGeX/2JUlE6g3l80b252tVhzKUATeFMAKKdl448FzYdt/vWJRq2dt1ActjDV/C9RpWMNHBw10cLS3/ivSVXnjNzANArDSOAdzIh2lnrauoEtIULqlKFImx4vk2B7Pt4Wg5+ouOGWbW8ZeU1zOqAQOlDSOggxEs+fOJvOrFZdVwyZ15UYX2gRnHc+aNT2gQd+HKwCJMrDbuxz9rYQe7SGfcgeT6vxz2ZLnZ2E5SIWP5QIhm+CboYypDCGh7O5FwBHoJCSEJW3mFu/pA01Hwz11ORS6UeD/z29k546YZRa0jrzD5dLJQE+Rc72cVJv05VLs+U30b4NHcmmjmdqoT/vfxto9XM+atN7D10+dNne59YmbL9TQyvDBnxwHIUoXXGDp5OLjjtlh2A/AFu4VtF/vhRolyvSnMfQznJnEBmDkIiW/V1qwI0TevOheG04ERHtFU5eGUYt7ofPAlkUrrJxEmuwSyVoApuI+lI5CaKD4dke0=" + + computedHash mustEqual expectedHash + } + + it("should be able to encrypt and decrypt text from a private key (AES-256-ctr)") { + val alg = "aes-256-ctr" + val key = "this-is-a-private-key" + val stringToEncrypt = "text-to-encrypt" + + val cipher = Crypto.createCipher(alg, key) + val encrypted = cipher.update(stringToEncrypt, "utf8", "base64") + val finalEncryptedValue = encrypted + cipher.`final`("base64") + + val decipher = Crypto.createDecipher(alg, key) + val decrypted = decipher.update(finalEncryptedValue, "base64", "utf8") + val finalDecryptedValue = decrypted + decipher.`final`("utf8") + + finalEncryptedValue mustNot equal(stringToEncrypt) + finalDecryptedValue must equal(stringToEncrypt) + } + } + + describe("Crypto module") { + it("has constants") { + assert(Crypto.constants.ENGINE_METHOD_DSA === 2) + } + } + describe("Crypto object") { describe("randomFillSync") { it("should accept Buffer and return value in type as received") { diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/dns/DNSAsyncTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/dns/DNSAsyncTest.scala index 9513cd1cd..455d4d407 100644 --- a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/dns/DNSAsyncTest.scala +++ b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/dns/DNSAsyncTest.scala @@ -3,7 +3,7 @@ package dns import org.scalatest.AsyncFunSpec -import scala.concurrent.ExecutionContext +import scala.concurrent.{ExecutionContext, Promise} import scala.scalajs.js /** @@ -15,6 +15,90 @@ class DNSAsyncTest extends AsyncFunSpec { override implicit val executionContext = ExecutionContext.Implicits.global + describe("DNS") { + it("supports lookup") { + val promise = Promise[String]() + DNS.lookup(domain, (err, ipAddress) => { + assert(err === null) + promise.success(ipAddress) + }) + promise.future.map { ipAddress => + assert(ipAddress.nonEmpty) + } + } + + it("supports lookupService:SSH") { + val promise = Promise[(String, String)]() + DNS.lookupService("127.0.0.1", 22, (err, hostname, service) => { + assert(err === null) + promise.success((hostname, service)) + }) + promise.future.map { + case (host, service) => + assert(host === "localhost") + assert(service === "ssh") + } + } + + it("supports resolve:NS") { + val promise = Promise[js.Array[String]]() + DNS.resolve( + domain, + "NS", + (err: DnsError, addresses: ResolveResult) => { + assert(err === null) + promise.success(addresses.asInstanceOf[js.Array[String]]) + } + ) + promise.future.map { addresses => + assert(addresses.nonEmpty) + } + } + } + + describe("DNS future extension") { + it("supports lookupFuture") { + DNS.lookupFuture(domain) map { + case (ipAddress, ttl) => + assert(ttl > 0 && ipAddress.nonEmpty) + } + } + + it("supports lookupServiceFuture:SSH") { + DNS.lookupServiceFuture("127.0.0.1", 22) map { + case (hostname, service) => + assert(hostname.nonEmpty && service.nonEmpty) + } + } + + it("supports resolveFuture:MX") { + DNS.resolveFuture(domain, RRTYPE_MX) map { response => + val result = response.asInstanceOf[js.Array[MX]] + assert(result(0).priority > 0 && result(0).exchange.nonEmpty) + } + } + + it("supports resolveFuture:NS") { + DNS.resolveFuture(domain, RRTYPE_NS) map { response => + val result = response.asInstanceOf[js.Array[String]] + assert(result(0).nonEmpty) + } + } + + it("supports resolveFuture:SOA") { + DNS.resolveFuture(domain, RRTYPE_SOA) map { response => + val result = response.asInstanceOf[SOA] + assert(result.expire > 0 && result.hostmaster.nonEmpty) + } + } + + it("supports reverseFuture") { + DNS.reverseFuture("216.58.218.142") map { hostnames => + assert(hostnames.nonEmpty && hostnames(0).nonEmpty) + } + } + } + describe("PromisesResolver") { it("supports resolveFuture:MX") { resolver.resolve(domain, RRTYPE_MX).toFuture map { response => diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/events/EventEmitterTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/events/EventEmitterTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/io/scalajs/nodejs/events/EventEmitterTest.scala rename to app/nodejs-v10/src/test/scala/io/scalajs/nodejs/events/EventEmitterTest.scala diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala rename to app/nodejs-v10/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/FsAsyncTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/fs/FsV8AsyncTest.scala similarity index 97% rename from app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/FsAsyncTest.scala rename to app/nodejs-v10/src/test/scala/io/scalajs/nodejs/fs/FsV8AsyncTest.scala index 2d8836bab..d5ba9ea3e 100644 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/FsAsyncTest.scala +++ b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/fs/FsV8AsyncTest.scala @@ -6,7 +6,7 @@ import org.scalatest.{AsyncFunSpec, BeforeAndAfterEach} import scala.concurrent.{ExecutionContext, Future} import scala.util.{Failure, Success} -class FsAsyncTest extends AsyncFunSpec with BeforeAndAfterEach { +class FsV8AsyncTest extends AsyncFunSpec with BeforeAndAfterEach { private val file = "x.File.txt" override def afterEach(): Unit = { diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/ReadStreamTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/fs/ReadStreamTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/ReadStreamTest.scala rename to app/nodejs-v10/src/test/scala/io/scalajs/nodejs/fs/ReadStreamTest.scala diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/http/HttpTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/http/HttpTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/io/scalajs/nodejs/http/HttpTest.scala rename to app/nodejs-v10/src/test/scala/io/scalajs/nodejs/http/HttpTest.scala diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/http/StatusCodeTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/http/StatusCodeTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/io/scalajs/nodejs/http/StatusCodeTest.scala rename to app/nodejs-v10/src/test/scala/io/scalajs/nodejs/http/StatusCodeTest.scala diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/http2/Http2HeadersTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/http2/Http2HeadersTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/io/scalajs/nodejs/http2/Http2HeadersTest.scala rename to app/nodejs-v10/src/test/scala/io/scalajs/nodejs/http2/Http2HeadersTest.scala diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/net/NetTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/net/NetTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/io/scalajs/nodejs/net/NetTest.scala rename to app/nodejs-v10/src/test/scala/io/scalajs/nodejs/net/NetTest.scala diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/os/OSTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/os/OSTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/io/scalajs/nodejs/os/OSTest.scala rename to app/nodejs-v10/src/test/scala/io/scalajs/nodejs/os/OSTest.scala diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/path/PathTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/path/PathTest.scala index 79a0baf3c..3d996597c 100644 --- a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/path/PathTest.scala +++ b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/path/PathTest.scala @@ -5,7 +5,37 @@ import org.scalatest.FunSpec class PathTest extends FunSpec { describe("Path") { + it("supports basename()") { + assert(Path.basename("/foo/bar/baz/asdf/quux.html") === "quux.html") + assert(Path.basename("/foo/bar/baz/asdf/quux.html", ".html") === "quux") + } + + it("supports posix.basename()") { + assert(Path.posix.basename("C:\\temp\\data.txt") === "C:\\temp\\data.txt") + assert(Path.posix.basename("/temp/data.txt") === "data.txt") + } + + it("supports win32.basename()") { + assert(Path.win32.basename("C:\\temp\\data.txt") === "data.txt") + assert(Path.win32.basename("/temp/data.txt") === "data.txt") + } + + it("supports format()") { + assert(Path.format(new PathObject(root = "/", base = "file.txt")) === "/file.txt") + } + + it("supports isAbsolute()") { + assert(Path.isAbsolute("/foo/bar")) + assert(Path.isAbsolute("/baz/..")) + assert(!Path.isAbsolute("qux/")) + assert(!Path.isAbsolute(".")) + } + it("supports join()") { + assert(Path.join("/foo", "bar", "baz/asdf", "quux", "..") === "/foo/bar/baz/asdf") + } + + it("supports os specific from Node.js v10") { assert(Path.win32.toNamespacedPath("c:\\foo\\bar") === "\\\\?\\c:\\foo\\bar") assert(Path.posix.toNamespacedPath("c:\\foo\\bar") === "c:\\foo\\bar") } diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/process/EnvironmentTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/process/EnvironmentTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/io/scalajs/nodejs/process/EnvironmentTest.scala rename to app/nodejs-v10/src/test/scala/io/scalajs/nodejs/process/EnvironmentTest.scala diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/process/ProcessTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/process/ProcessTest.scala index 772c7f2ee..520c2964c 100644 --- a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/process/ProcessTest.scala +++ b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/process/ProcessTest.scala @@ -1,9 +1,47 @@ package io.scalajs.nodejs.process +import io.scalajs.nodejs.os.OS +import io.scalajs.nodejs.TestEnvironment import org.scalatest.FunSpec class ProcessTest extends FunSpec { describe("Process") { + val versionPrefix = + if (TestEnvironment.isExecutedInExactNode8) "v8." + else if (TestEnvironment.isExecutedInExactNode10) "v10." + else if (TestEnvironment.isExecutedInExactNode12) "v12." + else "Unknown node.js version" + + it("contains the following properties") { + assert(Process.arch.isInstanceOf[String]) + assert(Process.argv.length === 1) + assert(Process.argv(0).endsWith("node")) + assert(Process.config.variables.host_arch === OS.arch()) + assert(Process.connected.isEmpty) + assert(Process.cwd().nonEmpty) + assert(Process.env("PATH").nonEmpty) + assert(Process.env.PATH === Process.env("PATH")) + assert(Process.execArgv.length === 0) + assert(Process.execPath.endsWith("node")) + assert(Process.features.contains("debug")) + assert(Process.moduleLoadList.length > 0) + assert(Process.title.isInstanceOf[String]) + assert(Process.version.startsWith(versionPrefix)) + assert(s"v${Process.versions.node}".startsWith(versionPrefix)) + + // TODO: actually undefined in test + // assert(process.stdout.isTTY) + // assert(process.stderr.isTTY) + } + + it("hrtime") { + val value = Process.hrtime() + assert(value.length === 2) + val diff = Process.hrtime(value) + assert(diff.length === 2) + assert(diff(0) === 0) + } + it("hrtime.bigint") { // TODO: js.BigInt val value = Process.hrtime.bigint() diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/querystring/QueryStringTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/querystring/QueryStringTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/io/scalajs/nodejs/querystring/QueryStringTest.scala rename to app/nodejs-v10/src/test/scala/io/scalajs/nodejs/querystring/QueryStringTest.scala diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/readline/ReadlineTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/readline/ReadlineTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/io/scalajs/nodejs/readline/ReadlineTest.scala rename to app/nodejs-v10/src/test/scala/io/scalajs/nodejs/readline/ReadlineTest.scala diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/tty/TTYTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/tty/TTYTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/io/scalajs/nodejs/tty/TTYTest.scala rename to app/nodejs-v10/src/test/scala/io/scalajs/nodejs/tty/TTYTest.scala diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/url/URLObjectTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/url/URLObjectTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/io/scalajs/nodejs/url/URLObjectTest.scala rename to app/nodejs-v10/src/test/scala/io/scalajs/nodejs/url/URLObjectTest.scala diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/url/URLSearchParamsTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/url/URLSearchParamsTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/io/scalajs/nodejs/url/URLSearchParamsTest.scala rename to app/nodejs-v10/src/test/scala/io/scalajs/nodejs/url/URLSearchParamsTest.scala diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/url/URLTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/url/URLTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/io/scalajs/nodejs/url/URLTest.scala rename to app/nodejs-v10/src/test/scala/io/scalajs/nodejs/url/URLTest.scala diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/util/UtilTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/util/UtilTest.scala index 1932bead9..933a59e2a 100644 --- a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/util/UtilTest.scala +++ b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/util/UtilTest.scala @@ -5,6 +5,28 @@ import org.scalatest.FunSpec import scala.scalajs.js class UtilTest extends FunSpec { + it("have inspect object") { + assert(Util.inspect !== null) + assert(Util.inspect(js.Array(1, 2, 3)) === "[ 1, 2, 3 ]") + val inspectOptions = new InspectOptions(maxArrayLength = 1) + assert(Util.inspect(js.Array(1, 2, 3), inspectOptions) === "[ 1, ... 2 more items ]") + assert(Util.inspect.defaultOptions !== null) + assert(Util.inspect.styles !== null) + } + + it("have promisify") { + assert(js.typeOf(Util.promisify(() => "")) === "function") + assert(js.typeOf(Util.promisify.custom) === "symbol") + } + + it("have TextEncoder/TextDecoder") { + val encoder = new TextEncoder() + val decoder = new TextDecoder() + val encoded = encoder.encode("foobar") + val decoded = decoder.decode(encoded) + assert(decoded === "foobar") + } + it("have formatWithOptions added in v10.0.0") { assert(Util.formatWithOptions(new InspectOptions(compact = true), "See object %O", new js.Object { val foo: Int = 42 diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/vm/VMTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/vm/VMTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/io/scalajs/nodejs/vm/VMTest.scala rename to app/nodejs-v10/src/test/scala/io/scalajs/nodejs/vm/VMTest.scala diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/zlib/ZlibTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/zlib/ZlibTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/io/scalajs/nodejs/zlib/ZlibTest.scala rename to app/nodejs-v10/src/test/scala/io/scalajs/nodejs/zlib/ZlibTest.scala diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/crypto/CertificateTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/crypto/CertificateTest.scala deleted file mode 100644 index 7db686fb5..000000000 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/crypto/CertificateTest.scala +++ /dev/null @@ -1,34 +0,0 @@ -package io.scalajs.nodejs.crypto - -import io.scalajs.nodejs.buffer.Buffer -import org.scalatest.{FunSpec, MustMatchers} - -class CertificateTest extends FunSpec with MustMatchers { - val spkacExample = - "MIIBXjCByDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA3L0IfUijj7+A8CPC8EmhcdNoe5fUAog7OrBdhn7EkxFButUp40P7+LiYiygYG1TmoI/a5EgsLU3s9twEz3hmgY9mYIqb/rb+SF8qlD/K6KVyUORC7Wlz1Df4L8O3DuRGzx6/+3jIW6cPBpfgH1sVuYS1vDBsP/gMMIxwTsKJ4P0CAwEAARYkYzBkZjFlYjctMTU0NC00MWVkLWFmN2EtZDRkYjBkNDc5ZjZmMA0GCSqGSIb3DQEBBAUAA4GBALEiapUjaIPs5uEdvCP0gFK2qofo+4GpeK1A43mu28lirYPAvCWsmYvKIZIT9TxvzmQIxAfxobf70aSNlSm6MJJKmvurAK+Bpn6ZUKQZ6A1m927LvctVSYJuUi+WVmr0fGE/OfdQ+BqSm/eQ3jnm3fBPVx1uwLPgjC5g4EvGMh8M" - - describe("Certificate class (Legacy)") { - val instance = new Certificate() - - it("exportChallenge") { - assert(instance.exportChallenge(spkacExample).toString("utf8") === "c0df1eb7-1544-41ed-af7a-d4db0d479f6f") - } - - it("exportPublicKey") { - assert( - instance.exportPublicKey(spkacExample).toString("utf8") === - """-----BEGIN PUBLIC KEY----- - |MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDcvQh9SKOPv4DwI8LwSaFx02h7 - |l9QCiDs6sF2GfsSTEUG61SnjQ/v4uJiLKBgbVOagj9rkSCwtTez23ATPeGaBj2Zg - |ipv+tv5IXyqUP8ropXJQ5ELtaXPUN/gvw7cO5EbPHr/7eMhbpw8Gl+AfWxW5hLW8 - |MGw/+AwwjHBOwong/QIDAQAB - |-----END PUBLIC KEY----- - |""".stripMargin - ) - } - - it("verifySpkac") { - assert(instance.verifySpkac(Buffer.from("foo")) === false) - } - } -} diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/crypto/CryptoTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/crypto/CryptoTest.scala deleted file mode 100644 index 97b5b802a..000000000 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/crypto/CryptoTest.scala +++ /dev/null @@ -1,58 +0,0 @@ -package io.scalajs.nodejs.crypto - -import org.scalatest.{FunSpec, MustMatchers} - -/** - * Crypto Test - */ -class CryptoTest extends FunSpec with MustMatchers { - describe("Crypto") { - val text = "Hello World" - - it("should be able to create an MD5 hash from a string") { - val hasher = Crypto.createHash("md5") - hasher.update(text) - val buffer = hasher.digest() - assert(buffer.toHexString === "b10a8db164e0754105b7a99be72e3fe5") - } - - it("should be able to create a SHA256 hash from a string") { - val hasher = Crypto.createHash("sha256") - hasher.update(text) - val buffer = hasher.digest() - assert(buffer.toHexString === "a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e") - } - - it("should be able to hash passwords with pbkdf2Sync") { - val computedHash = - Crypto.pbkdf2Sync("this-is-a-password", "random-salt", 10000, 512, "sha512").toString("base64") - val expectedHash = - "nzaxkuDuglFxKDMtr566d1mlr7kZV5y1j5PWpU9E/R9cpZz5q8pyYgeuTWADj2DhBF6koAsikPOac81lOHgK+tgiIYy6YRBd0SylsewT3QR5CelagTY1nrKougkJi95TmyKplJIO9M2szDqMhX5eT0yY2eVLnv9R0SCjd3qunvbVJmOvfEOgetPCwu5oUfRGeX/2JUlE6g3l80b252tVhzKUATeFMAKKdl448FzYdt/vWJRq2dt1ActjDV/C9RpWMNHBw10cLS3/ivSVXnjNzANArDSOAdzIh2lnrauoEtIULqlKFImx4vk2B7Pt4Wg5+ouOGWbW8ZeU1zOqAQOlDSOggxEs+fOJvOrFZdVwyZ15UYX2gRnHc+aNT2gQd+HKwCJMrDbuxz9rYQe7SGfcgeT6vxz2ZLnZ2E5SIWP5QIhm+CboYypDCGh7O5FwBHoJCSEJW3mFu/pA01Hwz11ORS6UeD/z29k546YZRa0jrzD5dLJQE+Rc72cVJv05VLs+U30b4NHcmmjmdqoT/vfxto9XM+atN7D10+dNne59YmbL9TQyvDBnxwHIUoXXGDp5OLjjtlh2A/AFu4VtF/vhRolyvSnMfQznJnEBmDkIiW/V1qwI0TevOheG04ERHtFU5eGUYt7ofPAlkUrrJxEmuwSyVoApuI+lI5CaKD4dke0=" - - computedHash mustEqual expectedHash - } - - it("should be able to encrypt and decrypt text from a private key (AES-256-ctr)") { - val alg = "aes-256-ctr" - val key = "this-is-a-private-key" - val stringToEncrypt = "text-to-encrypt" - - val cipher = Crypto.createCipher(alg, key) - val encrypted = cipher.update(stringToEncrypt, "utf8", "base64") - val finalEncryptedValue = encrypted + cipher.`final`("base64") - - val decipher = Crypto.createDecipher(alg, key) - val decrypted = decipher.update(finalEncryptedValue, "base64", "utf8") - val finalDecryptedValue = decrypted + decipher.`final`("utf8") - - finalEncryptedValue mustNot equal(stringToEncrypt) - finalDecryptedValue must equal(stringToEncrypt) - } - } - - describe("Crypto module") { - it("has constants") { - assert(Crypto.constants.ENGINE_METHOD_DSA === 2) - } - } -} diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/dns/DNSAsyncTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/dns/DNSAsyncTest.scala deleted file mode 100644 index ffd9fe42e..000000000 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/dns/DNSAsyncTest.scala +++ /dev/null @@ -1,97 +0,0 @@ -package io.scalajs.nodejs -package dns - -import org.scalatest.AsyncFunSpec - -import scala.concurrent.{ExecutionContext, Promise} -import scala.scalajs.js - -class DNSAsyncTest extends AsyncFunSpec { - override implicit val executionContext = ExecutionContext.Implicits.global - - private val domain = "google.com" - - describe("DNS") { - it("supports lookup") { - val promise = Promise[String]() - DNS.lookup(domain, (err, ipAddress) => { - assert(err === null) - promise.success(ipAddress) - }) - promise.future.map { ipAddress => - assert(ipAddress.nonEmpty) - } - } - - it("supports lookupService:SSH") { - val promise = Promise[(String, String)]() - DNS.lookupService("127.0.0.1", 22, (err, hostname, service) => { - assert(err === null) - promise.success((hostname, service)) - }) - promise.future.map { - case (host, service) => - assert(host === "localhost") - assert(service === "ssh") - } - } - - it("supports resolve:NS") { - val promise = Promise[js.Array[String]]() - DNS.resolve( - domain, - "NS", - (err: DnsError, addresses: ResolveResult) => { - assert(err === null) - promise.success(addresses.asInstanceOf[js.Array[String]]) - } - ) - promise.future.map { addresses => - assert(addresses.nonEmpty) - } - } - } - - describe("DNS future extension") { - it("supports lookupFuture") { - DNS.lookupFuture(domain) map { - case (ipAddress, ttl) => - assert(ttl > 0 && ipAddress.nonEmpty) - } - } - - it("supports lookupServiceFuture:SSH") { - DNS.lookupServiceFuture("127.0.0.1", 22) map { - case (hostname, service) => - assert(hostname.nonEmpty && service.nonEmpty) - } - } - - it("supports resolveFuture:MX") { - DNS.resolveFuture(domain, RRTYPE_MX) map { response => - val result = response.asInstanceOf[js.Array[MX]] - assert(result(0).priority > 0 && result(0).exchange.nonEmpty) - } - } - - it("supports resolveFuture:NS") { - DNS.resolveFuture(domain, RRTYPE_NS) map { response => - val result = response.asInstanceOf[js.Array[String]] - assert(result(0).nonEmpty) - } - } - - it("supports resolveFuture:SOA") { - DNS.resolveFuture(domain, RRTYPE_SOA) map { response => - val result = response.asInstanceOf[SOA] - assert(result.expire > 0 && result.hostmaster.nonEmpty) - } - } - - it("supports reverseFuture") { - DNS.reverseFuture("216.58.218.142") map { hostnames => - assert(hostnames.nonEmpty && hostnames(0).nonEmpty) - } - } - } -} diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/path/PathTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/path/PathTest.scala deleted file mode 100644 index f40b563ff..000000000 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/path/PathTest.scala +++ /dev/null @@ -1,40 +0,0 @@ -package io.scalajs.nodejs.path - -import org.scalatest.FunSpec - -/** - * Path Tests - */ -class PathTest extends FunSpec { - describe("Path") { - it("supports basename()") { - assert(Path.basename("/foo/bar/baz/asdf/quux.html") === "quux.html") - assert(Path.basename("/foo/bar/baz/asdf/quux.html", ".html") === "quux") - } - - it("supports posix.basename()") { - assert(Path.posix.basename("C:\\temp\\data.txt") === "C:\\temp\\data.txt") - assert(Path.posix.basename("/temp/data.txt") === "data.txt") - } - - it("supports win32.basename()") { - assert(Path.win32.basename("C:\\temp\\data.txt") === "data.txt") - assert(Path.win32.basename("/temp/data.txt") === "data.txt") - } - - it("supports format()") { - assert(Path.format(new PathObject(root = "/", base = "file.txt")) === "/file.txt") - } - - it("supports isAbsolute()") { - assert(Path.isAbsolute("/foo/bar")) - assert(Path.isAbsolute("/baz/..")) - assert(!Path.isAbsolute("qux/")) - assert(!Path.isAbsolute(".")) - } - - it("supports join()") { - assert(Path.join("/foo", "bar", "baz/asdf", "quux", "..") === "/foo/bar/baz/asdf") - } - } -} diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/process/ProcessTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/process/ProcessTest.scala deleted file mode 100644 index c20616684..000000000 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/process/ProcessTest.scala +++ /dev/null @@ -1,45 +0,0 @@ -package io.scalajs.nodejs.process - -import io.scalajs.nodejs.os.OS -import io.scalajs.nodejs.TestEnvironment -import org.scalatest.FunSpec - -class ProcessTest extends FunSpec { - describe("Process") { - val versionPrefix = - if (TestEnvironment.isExecutedInExactNode8) "v8." - else if (TestEnvironment.isExecutedInExactNode10) "v10." - else if (TestEnvironment.isExecutedInExactNode12) "v12." - else "Unknown node.js version" - - it("contains the following properties") { - assert(Process.arch.isInstanceOf[String]) - assert(Process.argv.length === 1) - assert(Process.argv(0).endsWith("node")) - assert(Process.config.variables.host_arch === OS.arch()) - assert(Process.connected.isEmpty) - assert(Process.cwd().nonEmpty) - assert(Process.env("PATH").nonEmpty) - assert(Process.env.PATH === Process.env("PATH")) - assert(Process.execArgv.length === 0) - assert(Process.execPath.endsWith("node")) - assert(Process.features.contains("debug")) - assert(Process.moduleLoadList.length > 0) - assert(Process.title.isInstanceOf[String]) - assert(Process.version.startsWith(versionPrefix)) - assert(s"v${Process.versions.node}".startsWith(versionPrefix)) - - // TODO: actually undefined in test - // assert(process.stdout.isTTY) - // assert(process.stderr.isTTY) - } - - it("hrtime") { - val value = Process.hrtime() - assert(value.length === 2) - val diff = Process.hrtime(value) - assert(diff.length === 2) - assert(diff(0) === 0) - } - } -} diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/util/UtilTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/util/UtilTest.scala deleted file mode 100644 index 1346dc788..000000000 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/util/UtilTest.scala +++ /dev/null @@ -1,29 +0,0 @@ -package io.scalajs.nodejs.util - -import org.scalatest.FunSpec - -import scala.scalajs.js - -class UtilTest extends FunSpec { - it("have inspect object") { - assert(Util.inspect !== null) - assert(Util.inspect(js.Array(1, 2, 3)) === "[ 1, 2, 3 ]") - val inspectOptions = new InspectOptions(maxArrayLength = 1) - assert(Util.inspect(js.Array(1, 2, 3), inspectOptions) === "[ 1, ... 2 more items ]") - assert(Util.inspect.defaultOptions !== null) - assert(Util.inspect.styles !== null) - } - - it("have promisify") { - assert(js.typeOf(Util.promisify(() => "")) === "function") - assert(js.typeOf(Util.promisify.custom) === "symbol") - } - - it("have TextEncoder/TextDecoder") { - val encoder = new TextEncoder() - val decoder = new TextDecoder() - val encoded = encoder.encode("foobar") - val decoded = decoder.decode(encoded) - assert(decoded === "foobar") - } -} From ab1135b8d0b73fe448935b8636c53911a60d03f7 Mon Sep 17 00:00:00 2001 From: exoego Date: Thu, 2 Jan 2020 09:26:59 +0900 Subject: [PATCH 2/4] Remove nodejs_v8 sub project --- build.sbt | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/build.sbt b/build.sbt index 6b17693f3..fa09e235e 100644 --- a/build.sbt +++ b/build.sbt @@ -1,7 +1,7 @@ organization in ThisBuild := "net.exoego" lazy val root = (project in file(".")) - .aggregate(core, current, nodejs_v10, nodejs_v8) + .aggregate(core, current, nodejs_v10) .settings(MySettings.commonSettings) .settings(MySettings.publishingSettings) .settings(MySettings.nonPublishingSetting) @@ -55,25 +55,3 @@ lazy val nodejs_v10 = (project in file("./app/nodejs-v10")) libraryDependencies ++= Dependencies.app.value ) .dependsOn(core) - -lazy val nodejs_v8 = (project in file("./app/nodejs-v8")) - .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 current).value / "src" / "main" / "scala").filter(_ => !hasSymlink) - }, - scalacOptions ++= Seq( - "-Xmacro-settings:nodeJs8.16.0" - ), - name := "scala-js-nodejs-v8", - description := "NodeJS v8.16.0 API for Scala.js", - homepage := Some(url("https://github.com/exoego/scala-js-nodejs")), - libraryDependencies ++= Dependencies.app.value - ) - .dependsOn(core) From 6711c022b1721aedfcafd9b8890f142e18a96e8f Mon Sep 17 00:00:00 2001 From: exoego Date: Thu, 2 Jan 2020 09:37:46 +0900 Subject: [PATCH 3/4] Remove unnecessary compiler switch --- .../main/scala/io/scalajs/nodejs/Assert.scala | 4 - .../main/scala/io/scalajs/nodejs/Module.scala | 1 - .../nodejs/cluster/ClusterSettings.scala | 3 - .../nodejs/console_module/Console.scala | 3 - .../scalajs/nodejs/crypto/Certificate.scala | 4 - .../io/scalajs/nodejs/crypto/Crypto.scala | 22 +---- .../scala/io/scalajs/nodejs/crypto/ECDH.scala | 2 - .../scalajs/nodejs/dns/PromiseResolver.scala | 3 - .../scalajs/nodejs/events/EventEmitter.scala | 2 - .../io/scalajs/nodejs/fs/FSConstants.scala | 8 +- .../main/scala/io/scalajs/nodejs/fs/Fs.scala | 23 +----- .../scala/io/scalajs/nodejs/fs/package.scala | 16 +--- .../scala/io/scalajs/nodejs/http/Http.scala | 2 - .../scalajs/nodejs/http/ServerResponse.scala | 1 - .../scalajs/nodejs/http2/Http2Constants.scala | 80 +++++++++---------- .../scalajs/nodejs/http2/Http2Session.scala | 13 --- .../io/scalajs/nodejs/http2/Http2Stream.scala | 7 -- .../nodejs/http2/ServerHttp2Session.scala | 4 - .../scala/io/scalajs/nodejs/https/Https.scala | 3 - .../io/scalajs/nodejs/https/package.scala | 2 - .../main/scala/io/scalajs/nodejs/os/OS.scala | 7 +- .../scala/io/scalajs/nodejs/path/Path.scala | 3 - .../io/scalajs/nodejs/process/Process.scala | 22 ++--- .../io/scalajs/nodejs/process/package.scala | 1 - .../io/scalajs/nodejs/repl/REPLServer.scala | 1 - .../io/scalajs/nodejs/stream/Stream.scala | 21 +---- .../io/scalajs/nodejs/stream/package.scala | 3 - .../io/scalajs/nodejs/timers/Immediate.scala | 2 - .../io/scalajs/nodejs/timers/Timeout.scala | 1 - .../io/scalajs/nodejs/tls/TLSSocket.scala | 1 - .../io/scalajs/nodejs/tty/WriteStream.scala | 1 - .../scala/io/scalajs/nodejs/url/URL.scala | 3 - .../scala/io/scalajs/nodejs/util/Util.scala | 8 -- .../scala/io/scalajs/nodejs/vm/Script.scala | 3 - .../main/scala/io/scalajs/nodejs/vm/VM.scala | 7 +- .../worker_threads/MessageChannel.scala | 3 - .../nodejs/worker_threads/MessagePort.scala | 2 - .../nodejs/worker_threads/MessagePoster.scala | 3 - .../nodejs/worker_threads/Worker.scala | 3 - .../nodejs/worker_threads/WorkerThreads.scala | 5 -- .../nodejs/internal/CompilerSwitches.scala | 6 -- 41 files changed, 57 insertions(+), 252 deletions(-) diff --git a/app/current/src/main/scala/io/scalajs/nodejs/Assert.scala b/app/current/src/main/scala/io/scalajs/nodejs/Assert.scala index 8c5954176..49066fa58 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/Assert.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/Assert.scala @@ -1,6 +1,5 @@ package io.scalajs.nodejs -import com.thoughtworks.enableIf import io.scalajs.nodejs.events.IEventEmitter import scala.scalajs.js @@ -32,7 +31,6 @@ trait Assert extends IEventEmitter { */ def deepStrictEqual(actual: js.Any, expected: js.Any, message: String = js.native): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def doesNotReject(asyncFn: js.Function | js.Promise[_], error: js.RegExp | js.Function = js.native, message: String = js.native): Unit = js.native @@ -100,7 +98,6 @@ trait Assert extends IEventEmitter { error: js.RegExp | js.Function | js.Object | Error, message: String = js.native): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def rejects(asyncFn: js.Function | js.Promise[_], error: js.RegExp | js.Function | js.Object | Error = js.native, message: String = js.native): Unit = js.native @@ -112,6 +109,5 @@ trait Assert extends IEventEmitter { @js.native @JSImport("assert", JSImport.Namespace) object Assert extends Assert { - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) val strict: Assert = js.native } diff --git a/app/current/src/main/scala/io/scalajs/nodejs/Module.scala b/app/current/src/main/scala/io/scalajs/nodejs/Module.scala index e681fc3f7..c7f82fbba 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/Module.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/Module.scala @@ -70,7 +70,6 @@ trait Module extends js.Object { @js.native @JSImport("module", JSImport.Namespace) object Module extends Module { - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) var builtinModules: js.Array[String] = js.native @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) diff --git a/app/current/src/main/scala/io/scalajs/nodejs/cluster/ClusterSettings.scala b/app/current/src/main/scala/io/scalajs/nodejs/cluster/ClusterSettings.scala index bb224f8f6..5d67e16ed 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/cluster/ClusterSettings.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/cluster/ClusterSettings.scala @@ -1,6 +1,5 @@ package io.scalajs.nodejs.cluster -import com.thoughtworks.enableIf import io.scalajs.nodejs.{GID, UID} import scala.scalajs.js @@ -34,10 +33,8 @@ trait ClusterSettings extends js.Object { var inspectPort: Int | js.Function = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) var cwd: String = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) var windowsHide: Boolean = js.native } diff --git a/app/current/src/main/scala/io/scalajs/nodejs/console_module/Console.scala b/app/current/src/main/scala/io/scalajs/nodejs/console_module/Console.scala index e32dc4769..367691321 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/console_module/Console.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/console_module/Console.scala @@ -1,6 +1,5 @@ package io.scalajs.nodejs.console_module -import com.thoughtworks.enableIf import io.scalajs.nodejs.stream.IWritable import scala.scalajs.js @@ -144,7 +143,6 @@ class Console protected () extends js.Object { * @param tabularData * @param properties Alternate properties for constructing the table. */ - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def table(tabularData: js.Any, properties: js.Array[String] = js.native): Unit = js.native /** @@ -164,7 +162,6 @@ class Console protected () extends js.Object { /** * Stops a timer that was previously started by calling [[time()]] and prints the result to `.stdout`.` */ - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def timeLog(label: String, data: js.Any*): Unit = js.native /** diff --git a/app/current/src/main/scala/io/scalajs/nodejs/crypto/Certificate.scala b/app/current/src/main/scala/io/scalajs/nodejs/crypto/Certificate.scala index 433eea703..ed6d6efc9 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/crypto/Certificate.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/crypto/Certificate.scala @@ -1,6 +1,5 @@ package io.scalajs.nodejs.crypto -import com.thoughtworks.enableIf import io.scalajs.nodejs.buffer.Buffer import scala.scalajs.js @@ -18,12 +17,9 @@ class Certificate extends js.Object { @js.native @JSImport("crypto", "Certificate") object Certificate extends js.Object { - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def exportChallenge(spkac: String | BufferLike): Buffer = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def exportPublicKey(spkac: String | BufferLike, encoding: String = js.native): Buffer = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def verifySpkac(spkac: BufferLike): Boolean = js.native } diff --git a/app/current/src/main/scala/io/scalajs/nodejs/crypto/Crypto.scala b/app/current/src/main/scala/io/scalajs/nodejs/crypto/Crypto.scala index 35aff378a..490a128be 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/crypto/Crypto.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/crypto/Crypto.scala @@ -52,7 +52,6 @@ trait Crypto extends js.Object { @deprecated("Use crypto.createCipheriv() instead.", "Node.js v10.0") def createCipher(algorithm: String, password: Buffer | String): Cipher = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def createCipheriv(algorithm: String, key: String | BufferLike, iv: String | BufferLike, @@ -76,17 +75,15 @@ trait Crypto extends js.Object { */ @deprecated("Use crypto.createDecipheriv() instead.", "Node.js v10.0") def createDecipher(algorithm: String, password: Buffer | String): Decipher = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) + def createDecipheriv(algorithm: String, key: String | BufferLike, iv: String | BufferLike, options: TransformOptions = js.native): Decipher = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def createDecipheriv(algorithm: String, key: KeyObject, iv: String | BufferLike, - options: TransformOptions): Decipher = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) + options: TransformOptions): Decipher = js.native def createDecipheriv(algorithm: String, key: KeyObject, iv: String | BufferLike): Decipher = js.native def createDiffieHellman(prime: String, primeEncoding: String, generator: Int | BufferLike): DiffieHellman = js.native @@ -151,14 +148,12 @@ trait Crypto extends js.Object { */ def createVerify(algorithm: String, options: WritableOptions = js.native): Verify = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def generateKeyPair( `type`: String, options: GenerateKeyPairOptions, callback: Callback2[String | Buffer | KeyObject, String | Buffer | KeyObject] ): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def generateKeyPairSync(`type`: String, options: GenerateKeyPairOptions): KeyPair = js.native /** @@ -171,7 +166,6 @@ trait Crypto extends js.Object { def getDiffieHellman(groupName: String): DiffieHellmanGroup = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def getFips(): Boolean = js.native def getHashes(): js.Array[String] = js.native @@ -227,16 +221,12 @@ trait Crypto extends js.Object { def randomFillSync(buffer: Buffer, offset: Int): Buffer = js.native def randomFillSync(buffer: Buffer): Buffer = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def randomFillSync(buffer: scala.scalajs.js.typedarray.DataView, offset: Int, size: Int): scala.scalajs.js.typedarray.DataView = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def randomFillSync(buffer: scala.scalajs.js.typedarray.DataView, offset: Int): scala.scalajs.js.typedarray.DataView = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def randomFillSync(buffer: scala.scalajs.js.typedarray.DataView): scala.scalajs.js.typedarray.DataView = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def randomFillSync[T <: scala.scalajs.js.typedarray.TypedArray[_, T]](buffer: T, offset: Int = js.native, size: Int = js.native): T = js.native @@ -245,36 +235,29 @@ trait Crypto extends js.Object { def randomFill(buffer: Buffer, offset: Int, callback: Callback1[Buffer]): Buffer = js.native def randomFill(buffer: Buffer, callback: Callback1[Buffer]): Buffer = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def randomFill(buffer: scala.scalajs.js.typedarray.DataView, offset: Int, size: Int, callback: Callback1[scala.scalajs.js.typedarray.DataView]): scala.scalajs.js.typedarray.DataView = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def randomFill(buffer: scala.scalajs.js.typedarray.DataView, offset: Int, callback: Callback1[scala.scalajs.js.typedarray.DataView]): scala.scalajs.js.typedarray.DataView = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def randomFill(buffer: scala.scalajs.js.typedarray.DataView, callback: Callback1[scala.scalajs.js.typedarray.DataView]): scala.scalajs.js.typedarray.DataView = js.native - - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def randomFill[T <: scala.scalajs.js.typedarray.TypedArray[_, T]](buffer: T, offset: Int = js.native, size: Int = js.native, callback: Callback1[T]): T = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def scrypt(password: String | BufferLike, salt: String | BufferLike, keylen: Int, options: ScryptOptions = js.native, callback: Callback1[Buffer]): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def scryptSync(password: String | BufferLike, salt: String | BufferLike, keylen: Int, @@ -282,7 +265,6 @@ trait Crypto extends js.Object { def setEngine(engine: String, fips: Int = js.native): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def setFips(enable: Boolean): Unit = js.native @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) diff --git a/app/current/src/main/scala/io/scalajs/nodejs/crypto/ECDH.scala b/app/current/src/main/scala/io/scalajs/nodejs/crypto/ECDH.scala index 51e0703ac..f88005a44 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/crypto/ECDH.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/crypto/ECDH.scala @@ -1,6 +1,5 @@ package io.scalajs.nodejs.crypto -import com.thoughtworks.enableMembersIf import io.scalajs.nodejs.buffer.Buffer import scala.scalajs.js @@ -31,7 +30,6 @@ trait ECDH extends js.Object { } @js.native -@enableMembersIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) @JSImport("crypto", "ECDH") object ECDH extends js.Object { def convertKey(key: String, curve: String, inputEncoding: String, outputEncoding: String, format: String): String = diff --git a/app/current/src/main/scala/io/scalajs/nodejs/dns/PromiseResolver.scala b/app/current/src/main/scala/io/scalajs/nodejs/dns/PromiseResolver.scala index b596dab8c..743dc63ec 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/dns/PromiseResolver.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/dns/PromiseResolver.scala @@ -1,12 +1,9 @@ package io.scalajs.nodejs.dns -import com.thoughtworks.enableMembersIf - import scala.scalajs.js import scala.scalajs.js.annotation.JSImport @js.native -@enableMembersIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) @JSImport("dns", "promises.Resolver") class PromisesResolver extends js.Object { def getServers(): js.Array[String] = js.native diff --git a/app/current/src/main/scala/io/scalajs/nodejs/events/EventEmitter.scala b/app/current/src/main/scala/io/scalajs/nodejs/events/EventEmitter.scala index c6fd768c0..bc557b76e 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/events/EventEmitter.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/events/EventEmitter.scala @@ -73,7 +73,6 @@ trait IEventEmitter extends js.Object { */ def listeners(eventName: String): js.Array[js.Function] = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def off(eventName: String, listner: js.Function): this.type = js.native /** @@ -131,7 +130,6 @@ trait IEventEmitter extends js.Object { */ def setMaxListeners(n: Int): this.type = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def rawListeners(eventName: String): js.Array[js.Function] = js.native } diff --git a/app/current/src/main/scala/io/scalajs/nodejs/fs/FSConstants.scala b/app/current/src/main/scala/io/scalajs/nodejs/fs/FSConstants.scala index 10c09684b..c2570416d 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/fs/FSConstants.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/fs/FSConstants.scala @@ -1,8 +1,6 @@ package io.scalajs.nodejs package fs -import com.thoughtworks.enableIf - import scala.scalajs.js /** @@ -194,9 +192,7 @@ trait FSConstants extends js.Object { ///////////////////////////////////////////////////////////////////////////////// // File Copy Constants ///////////////////////////////////////////////////////////////////////////////// - val COPYFILE_EXCL: Int = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) - val COPYFILE_FICLONE: Int = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) + val COPYFILE_EXCL: Int = js.native + val COPYFILE_FICLONE: Int = js.native val COPYFILE_FICLONE_FORCE: Int = js.native } diff --git a/app/current/src/main/scala/io/scalajs/nodejs/fs/Fs.scala b/app/current/src/main/scala/io/scalajs/nodejs/fs/Fs.scala index 1b291328d..ca532a28d 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/fs/Fs.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/fs/Fs.scala @@ -1,7 +1,7 @@ package io.scalajs.nodejs package fs -import com.thoughtworks.{enableIf, enableMembersIf} +import com.thoughtworks.enableIf import io.scalajs.nodejs.buffer.Buffer import io.scalajs.nodejs.events.IEventEmitter @@ -399,7 +399,6 @@ trait Fs extends IEventEmitter with FSConstants { */ def linkSync(existingPath: Path, newPath: Path): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def lstat(path: Path, options: StatOptions, callback: FsCallback1[Stats]): Unit = js.native /** @@ -418,7 +417,6 @@ trait Fs extends IEventEmitter with FSConstants { */ def lstatSync(path: Path): Stats = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def lstatSync(path: Path, options: StatOptions): Stats = js.native /** @@ -433,7 +431,6 @@ trait Fs extends IEventEmitter with FSConstants { * mode defaults to 0o777. * @example fs.mkdir(path[, mode], callback) */ - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def mkdir(path: Path, mode: MkdirOptions, callback: FsCallback0): Unit = js.native /** @@ -450,7 +447,6 @@ trait Fs extends IEventEmitter with FSConstants { */ def mkdirSync(path: Path, mode: FileMode = js.native): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def mkdirSync(path: Path, mode: MkdirOptions): Unit = js.native /** @@ -580,7 +576,6 @@ trait Fs extends IEventEmitter with FSConstants { position: Int | Null, callback: FsCallback2[Int, Buffer]): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def read(fd: FileDescriptor, buffer: BufferLike, offset: Int | Null, @@ -600,7 +595,6 @@ trait Fs extends IEventEmitter with FSConstants { */ def readSync(fd: FileDescriptor, buffer: Buffer, offset: Int, length: Int, position: Int): Int = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def readSync(fd: FileDescriptor, buffer: BufferLike, offset: Int, length: Int, position: Int): Int = js.native /** @@ -615,8 +609,7 @@ trait Fs extends IEventEmitter with FSConstants { * @example fs.readdir(path[, options], callback) */ def readdir(path: Path, options: String | FileEncodingOptions, callback: FsCallback1[ReaddirArrays]): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) - def readdir(path: Path, options: ReaddirOptions, callback: FsCallback1[ReaddirArrays2]): Unit = js.native + def readdir(path: Path, options: ReaddirOptions, callback: FsCallback1[ReaddirArrays2]): Unit = js.native /** * Asynchronous readdir(3). Reads the contents of a directory. @@ -760,7 +753,6 @@ trait Fs extends IEventEmitter with FSConstants { def realpathSync(path: Path, options: FileEncodingOptions = js.native): Output = js.native def realpathSync(path: Path): String = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) val realpath: RealpathObject = js.native /** @@ -806,7 +798,6 @@ trait Fs extends IEventEmitter with FSConstants { */ def stat(path: Path, callback: FsCallback1[Stats]): Stats = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def stat(path: Path, options: StatOptions, callback: FsCallback1[Stats]): Stats = js.native /** @@ -815,7 +806,6 @@ trait Fs extends IEventEmitter with FSConstants { */ def statSync(path: Path): Stats = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def statSync(path: Path, options: StatOptions): Stats = js.native /** @@ -1011,7 +1001,6 @@ trait Fs extends IEventEmitter with FSConstants { position: Int | Null, callback: FsCallback2[Int, Buffer]): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def write(fd: FileDescriptor, buffer: BufferLike, offset: Int | Null, @@ -1056,10 +1045,8 @@ trait Fs extends IEventEmitter with FSConstants { def writeFile(file: String, data: String, options: FileWriteOptions, callback: FsCallback0): Unit = js.native def writeFile(file: String, data: String, callback: FsCallback0): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def writeFile(file: String, data: BufferLike, options: FileWriteOptions, callback: FsCallback0): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def writeFile(file: String, data: BufferLike, callback: FsCallback0): Unit = js.native /** @@ -1074,10 +1061,8 @@ trait Fs extends IEventEmitter with FSConstants { def writeFileSync(file: Path | FileDescriptor, data: String, options: FileWriteOptions): Unit = js.native def writeFileSync(file: Path | FileDescriptor, data: String): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def writeFileSync(file: Path | FileDescriptor, data: BufferLike, options: FileWriteOptions): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def writeFileSync(file: Path | FileDescriptor, data: BufferLike): Unit = js.native /** @@ -1132,7 +1117,6 @@ trait Fs extends IEventEmitter with FSConstants { @js.native @JSImport("fs", JSImport.Namespace) object Fs extends Fs { - @enableMembersIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) @js.native trait FsPromises extends js.Object { def access(path: Path, mode: FileMode): js.Promise[Unit] = js.native @@ -1172,7 +1156,6 @@ object Fs extends Fs { js.native } - @enableMembersIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) @js.native trait FileHandle extends js.Object { val fd: FileDescriptor = js.native @@ -1210,10 +1193,8 @@ object Fs extends Fs { def writev(buffers: js.Array[js.typedarray.ArrayBufferView], position: Int | Null): js.Promise[Unit] = js.native } - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) val promises: FsPromises = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) @js.native class Dirent() extends js.Object { def isBlockDevice(): Boolean = js.native diff --git a/app/current/src/main/scala/io/scalajs/nodejs/fs/package.scala b/app/current/src/main/scala/io/scalajs/nodejs/fs/package.scala index 44cf708bc..c0a5a81d3 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/fs/package.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/fs/package.scala @@ -19,11 +19,9 @@ package object fs { type Output = String | Buffer type FileWriteOptions = FileAppendOptions - type ReaddirArrays = js.Array[String] | js.Array[Buffer] - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) + type ReaddirArrays = js.Array[String] | js.Array[Buffer] type ReaddirArrays2 = ReaddirArrays | js.Array[fs.Dirent] - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) type Dirent = Fs.Dirent ///////////////////////////////////////////////////////////////////////////////// @@ -131,7 +129,6 @@ package object fs { } @inline - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def lstatFuture(path: Path, options: StatOptions): Future[Stats] = { promiseWithError1[FileIOError, Stats](instance.lstat(path, options, _)) } @@ -151,20 +148,17 @@ package object fs { promiseWithError0[FileIOError](instance.mkdir(path, _)) } - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) @inline def mkdirFuture(path: Path, options: MkdirOptions): Future[Unit] = { promiseWithError0[FileIOError](instance.mkdir(path, options, _)) } - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) @inline def mkdirRecursiveFuture(path: Path): Future[Unit] = { val recursiveEnabled = new MkdirOptions(recursive = true) promiseWithError0[FileIOError](instance.mkdir(path, recursiveEnabled, _)) } - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) @inline def mkdirRecursiveFuture(path: Path, options: MkdirOptions): Future[Unit] = { val recursiveEnabled = new MkdirOptions( @@ -237,7 +231,6 @@ package object fs { promiseWithError1[FileIOError, js.Array[Buffer]](callback) } - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) @inline def readdirDirentFuture(path: Buffer | String): Future[js.Array[Dirent]] = { val callback: FsCallback1[js.Array[Dirent]] => Unit = { callback => @@ -285,19 +278,16 @@ package object fs { promiseWithError1[FileIOError, Output](instance.realpath(file, options, _)) } - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) @inline def realpathNativeFuture(file: Path, options: FileEncodingOptions): Future[Output] = { promiseWithError1[FileIOError, Output](instance.realpath.native(file, options, _)) } - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) @inline def realpathNativeFuture(file: Path, encoding: String): Future[Output] = { promiseWithError1[FileIOError, Output](instance.realpath.native(file, encoding, _)) } - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) @inline def realpathNativeFuture(file: Path): Future[String] = { promiseWithError1[FileIOError, String](instance.realpath.native(file, _)) @@ -333,7 +323,6 @@ package object fs { @inline def statFuture(path: Path): Future[Stats] = promiseWithError1[FileIOError, Stats](instance.stat(path, _)) - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) @inline def statFuture(path: Path, options: StatOptions): Future[Stats] = { promiseWithError1[FileIOError, Stats](instance.stat(path, options, _)) @@ -399,7 +388,6 @@ package object fs { promiseWithError2[FileIOError, Int, Buffer](instance.write(fd, buffer, offset, length, position, _)) } - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) @inline def writeFuture(fd: FileDescriptor, buffer: BufferLike, @@ -429,13 +417,11 @@ package object fs { promiseWithError0[FileIOError](instance.writeFile(file, data, options, _)) } - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) @inline def writeFileFuture(file: String, data: BufferLike): Future[Unit] = { promiseWithError0[FileIOError](instance.writeFile(file, data, _)) } - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) @inline def writeFileFuture(file: String, data: BufferLike, options: FileWriteOptions): Future[Unit] = { promiseWithError0[FileIOError](instance.writeFile(file, data, options, _)) diff --git a/app/current/src/main/scala/io/scalajs/nodejs/http/Http.scala b/app/current/src/main/scala/io/scalajs/nodejs/http/Http.scala index 8f5539fd9..b6065a9f6 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/http/Http.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/http/Http.scala @@ -46,7 +46,6 @@ trait Http extends js.Object { js.native def createServer(requestListener: js.Function2[ClientRequest, ServerResponse, Any] = js.native): Server = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def get(url: String | URL, options: RequestOptions, callback: js.Function1[ServerResponse, Any] = js.native): ClientRequest = js.native @@ -58,7 +57,6 @@ trait Http extends js.Object { @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def maxHeaderSize: Int = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def request(url: String | URL, options: RequestOptions, callback: js.Function1[ServerResponse, Any] = js.native): Unit = js.native diff --git a/app/current/src/main/scala/io/scalajs/nodejs/http/ServerResponse.scala b/app/current/src/main/scala/io/scalajs/nodejs/http/ServerResponse.scala index f67532b05..ce8c91642 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/http/ServerResponse.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/http/ServerResponse.scala @@ -139,7 +139,6 @@ trait ServerResponse extends stream.Writable { def writeHead(statusCode: Int, headers: js.Object | js.Dictionary[_]): Unit = js.native def writeHead(statusCode: Int): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def writeProcessing(): Unit = js.native } diff --git a/app/current/src/main/scala/io/scalajs/nodejs/http2/Http2Constants.scala b/app/current/src/main/scala/io/scalajs/nodejs/http2/Http2Constants.scala index 5221d52f7..e0c1ecac1 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/http2/Http2Constants.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/http2/Http2Constants.scala @@ -1,7 +1,5 @@ package io.scalajs.nodejs.http2 -import com.thoughtworks.enableIf - import scala.scalajs.js @js.native @@ -86,8 +84,7 @@ trait Http2Constants extends js.Object { val HTTP2_HEADER_WWW_AUTHENTICATE: String = js.native val HTTP2_HEADER_X_CONTENT_TYPE_OPTIONS: String = js.native val HTTP2_HEADER_X_FRAME_OPTIONS: String = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) - val HTTP2_HEADER_PROTOCOL: String = js.native + val HTTP2_HEADER_PROTOCOL: String = js.native val HTTP2_METHOD_ACL: String = js.native val HTTP2_METHOD_BASELINE_CONTROL: String = js.native @@ -197,44 +194,43 @@ trait Http2Constants extends js.Object { val MAX_MAX_FRAME_SIZE: Int = js.native val MIN_MAX_FRAME_SIZE: Int = js.native - val NGHTTP2_CANCEL: Int = js.native - val NGHTTP2_COMPRESSION_ERROR: Int = js.native - val NGHTTP2_CONNECT_ERROR: Int = js.native - val NGHTTP2_DEFAULT_WEIGHT: Int = js.native - val NGHTTP2_ENHANCE_YOUR_CALM: Int = js.native - val NGHTTP2_ERR_FRAME_SIZE_ERROR: Int = js.native - val NGHTTP2_FLAG_ACK: Int = js.native - val NGHTTP2_FLAG_END_HEADERS: Int = js.native - val NGHTTP2_FLAG_END_STREAM: Int = js.native - val NGHTTP2_FLAG_NONE: Int = js.native - val NGHTTP2_FLAG_PADDED: Int = js.native - val NGHTTP2_FLAG_PRIORITY: Int = js.native - val NGHTTP2_FLOW_CONTROL_ERROR: Int = js.native - val NGHTTP2_FRAME_SIZE_ERROR: Int = js.native - val NGHTTP2_HTTP_1_1_REQUIRED: Int = js.native - val NGHTTP2_INADEQUATE_SECURITY: Int = js.native - val NGHTTP2_INTERNAL_ERROR: Int = js.native - val NGHTTP2_NO_ERROR: Int = js.native - val NGHTTP2_PROTOCOL_ERROR: Int = js.native - val NGHTTP2_REFUSED_STREAM: Int = js.native - val NGHTTP2_SESSION_CLIENT: Int = js.native - val NGHTTP2_SESSION_SERVER: Int = js.native - val NGHTTP2_SETTINGS_ENABLE_PUSH: Int = js.native - val NGHTTP2_SETTINGS_HEADER_TABLE_SIZE: Int = js.native - val NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE: Int = js.native - val NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS: Int = js.native - val NGHTTP2_SETTINGS_MAX_FRAME_SIZE: Int = js.native - val NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE: Int = js.native - val NGHTTP2_SETTINGS_TIMEOUT: Int = js.native - val NGHTTP2_STREAM_CLOSED: Int = js.native - val NGHTTP2_STREAM_STATE_CLOSED: Int = js.native - val NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL: Int = js.native - val NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE: Int = js.native - val NGHTTP2_STREAM_STATE_IDLE: Int = js.native - val NGHTTP2_STREAM_STATE_OPEN: Int = js.native - val NGHTTP2_STREAM_STATE_RESERVED_LOCAL: Int = js.native - val NGHTTP2_STREAM_STATE_RESERVED_REMOTE: Int = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) + val NGHTTP2_CANCEL: Int = js.native + val NGHTTP2_COMPRESSION_ERROR: Int = js.native + val NGHTTP2_CONNECT_ERROR: Int = js.native + val NGHTTP2_DEFAULT_WEIGHT: Int = js.native + val NGHTTP2_ENHANCE_YOUR_CALM: Int = js.native + val NGHTTP2_ERR_FRAME_SIZE_ERROR: Int = js.native + val NGHTTP2_FLAG_ACK: Int = js.native + val NGHTTP2_FLAG_END_HEADERS: Int = js.native + val NGHTTP2_FLAG_END_STREAM: Int = js.native + val NGHTTP2_FLAG_NONE: Int = js.native + val NGHTTP2_FLAG_PADDED: Int = js.native + val NGHTTP2_FLAG_PRIORITY: Int = js.native + val NGHTTP2_FLOW_CONTROL_ERROR: Int = js.native + val NGHTTP2_FRAME_SIZE_ERROR: Int = js.native + val NGHTTP2_HTTP_1_1_REQUIRED: Int = js.native + val NGHTTP2_INADEQUATE_SECURITY: Int = js.native + val NGHTTP2_INTERNAL_ERROR: Int = js.native + val NGHTTP2_NO_ERROR: Int = js.native + val NGHTTP2_PROTOCOL_ERROR: Int = js.native + val NGHTTP2_REFUSED_STREAM: Int = js.native + val NGHTTP2_SESSION_CLIENT: Int = js.native + val NGHTTP2_SESSION_SERVER: Int = js.native + val NGHTTP2_SETTINGS_ENABLE_PUSH: Int = js.native + val NGHTTP2_SETTINGS_HEADER_TABLE_SIZE: Int = js.native + val NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE: Int = js.native + val NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS: Int = js.native + val NGHTTP2_SETTINGS_MAX_FRAME_SIZE: Int = js.native + val NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE: Int = js.native + val NGHTTP2_SETTINGS_TIMEOUT: Int = js.native + val NGHTTP2_STREAM_CLOSED: Int = js.native + val NGHTTP2_STREAM_STATE_CLOSED: Int = js.native + val NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL: Int = js.native + val NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE: Int = js.native + val NGHTTP2_STREAM_STATE_IDLE: Int = js.native + val NGHTTP2_STREAM_STATE_OPEN: Int = js.native + val NGHTTP2_STREAM_STATE_RESERVED_LOCAL: Int = js.native + val NGHTTP2_STREAM_STATE_RESERVED_REMOTE: Int = js.native val NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL: Int = js.native val PADDING_STRATEGY_ALIGNED: Int = js.native diff --git a/app/current/src/main/scala/io/scalajs/nodejs/http2/Http2Session.scala b/app/current/src/main/scala/io/scalajs/nodejs/http2/Http2Session.scala index a1d70e224..c0e814164 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/http2/Http2Session.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/http2/Http2Session.scala @@ -1,6 +1,5 @@ package io.scalajs.nodejs.http2 -import com.thoughtworks.enableIf import io.scalajs.nodejs.events.IEventEmitter import io.scalajs.nodejs.{Error, net, tls} @@ -10,16 +9,12 @@ import scala.scalajs.js.| @js.native trait Http2Session extends IEventEmitter { - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def alpnProtocol: js.UndefOr[String] = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def close(callback: js.Function = js.native): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def closed: Boolean = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def connecting: Boolean = js.native def destroy(error: Error, code: Int): Unit = js.native @@ -29,25 +24,19 @@ trait Http2Session extends IEventEmitter { def destroyed: Boolean = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def encrypted: Boolean = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def goaway(code: Int, lastStreamID: Int, opaqueData: TypedArray[_, _] | DataView): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def goaway(code: Int, lastStreamID: Int): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def goaway(code: Int): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def goaway(): Unit = js.native def localSettings: Http2Settings = js.native def remoteSettings: Http2Settings = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def originSet: js.UndefOr[js.Array[String]] def pendingSettingsAck: Boolean = js.native @@ -56,7 +45,6 @@ trait Http2Session extends IEventEmitter { def ping(callback: js.Function): Boolean = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def ref(): Unit = js.native def setTimeout(msec: Int, callback: js.Function): Unit = js.native @@ -70,6 +58,5 @@ trait Http2Session extends IEventEmitter { def `type`: Int = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def unref(): Unit = js.native } diff --git a/app/current/src/main/scala/io/scalajs/nodejs/http2/Http2Stream.scala b/app/current/src/main/scala/io/scalajs/nodejs/http2/Http2Stream.scala index c57e2423d..b0e459981 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/http2/Http2Stream.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/http2/Http2Stream.scala @@ -14,28 +14,22 @@ trait Http2Stream extends stream.Duplex { def close(code: Int, callback: js.Function = js.native): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def closed: Boolean = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def endAfterHeaders: Boolean = js.native def id: js.UndefOr[Int] = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def pending: Boolean = js.native def priority(options: Http2Priority): Unit = js.native def rstCode: Int = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def sentHeaders: Http2Headers = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def sentInfoHeaders: js.Array[Http2Headers] = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def sentTrailers: Http2Headers = js.native def session: Http2Session = js.native @@ -44,6 +38,5 @@ trait Http2Stream extends stream.Duplex { def state: Http2StreamState = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def sendTrailers(headers: Http2Headers): Unit = js.native } diff --git a/app/current/src/main/scala/io/scalajs/nodejs/http2/ServerHttp2Session.scala b/app/current/src/main/scala/io/scalajs/nodejs/http2/ServerHttp2Session.scala index 02086abc6..95bc2cca2 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/http2/ServerHttp2Session.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/http2/ServerHttp2Session.scala @@ -1,14 +1,10 @@ package io.scalajs.nodejs.http2 -import com.thoughtworks.enableIf - import scala.scalajs.js @js.native trait ServerHttp2Session extends Http2Session { - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def altsvc(alt: String, originOrStream: js.|[Int, Origin]): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def origin(origins: Origin*): Unit = js.native } diff --git a/app/current/src/main/scala/io/scalajs/nodejs/https/Https.scala b/app/current/src/main/scala/io/scalajs/nodejs/https/Https.scala index 1241bb1d4..4becfd859 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/https/Https.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/https/Https.scala @@ -1,6 +1,5 @@ package io.scalajs.nodejs.https -import com.thoughtworks.enableIf import io.scalajs.nodejs.http.{ClientRequest, RequestOptions, ServerResponse} import io.scalajs.nodejs.url.URL @@ -37,13 +36,11 @@ trait Https extends js.Object { def createServer(options: ServerOptions): Server = js.native def createServer(): Server = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def get(url: String | URL, options: RequestOptions, callback: js.Function1[ServerResponse, Any]): ClientRequest = js.native def get(url: String | URL, callback: js.Function1[ServerResponse, Any]): ClientRequest = js.native def get(options: RequestOptions, callback: js.Function): ClientRequest = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def request(url: String | URL, options: RequestOptions, callback: js.Function1[ServerResponse, Any] = js.native): Unit = js.native diff --git a/app/current/src/main/scala/io/scalajs/nodejs/https/package.scala b/app/current/src/main/scala/io/scalajs/nodejs/https/package.scala index 6aed1e94f..9d4802af0 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/https/package.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/https/package.scala @@ -1,6 +1,5 @@ package io.scalajs.nodejs -import com.thoughtworks.enableIf import io.scalajs.nodejs.http.{RequestOptions, ServerResponse} import io.scalajs.util.PromiseHelper._ import io.scalajs.nodejs.url.URL @@ -50,7 +49,6 @@ package object https { promiseCallback1[ServerResponse](https.request(url, _)) } - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) @inline def requestFuture(url: String | URL, options: RequestOptions): Future[ServerResponse] = { promiseCallback1[ServerResponse](https.request(url, options, _)) diff --git a/app/current/src/main/scala/io/scalajs/nodejs/os/OS.scala b/app/current/src/main/scala/io/scalajs/nodejs/os/OS.scala index b427de799..9807df8f1 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/os/OS.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/os/OS.scala @@ -1,7 +1,5 @@ package io.scalajs.nodejs.os -import com.thoughtworks.enableIf - import scala.scalajs.js import scala.scalajs.js.annotation.JSImport @@ -65,7 +63,6 @@ trait OS extends js.Object { */ def freemem(): Double = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def getPriority(pid: Int = js.native): Int = js.native /** @@ -112,10 +109,8 @@ trait OS extends js.Object { */ def release(): String = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def setPriority(pid: Int, priority: Int): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) - def setPriority(priority: Int): Unit = js.native + def setPriority(priority: Int): Unit = js.native /** * Returns the operating system's default directory for temporary files. diff --git a/app/current/src/main/scala/io/scalajs/nodejs/path/Path.scala b/app/current/src/main/scala/io/scalajs/nodejs/path/Path.scala index fc212389d..2059099d3 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/path/Path.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/path/Path.scala @@ -1,7 +1,5 @@ package io.scalajs.nodejs.path -import com.thoughtworks.enableIf - import scala.scalajs.js import scala.scalajs.js.annotation.JSImport @@ -134,7 +132,6 @@ trait Path extends js.Object { */ def resolve(args: String*): String = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def toNamespacedPath(path: String): String = js.native } diff --git a/app/current/src/main/scala/io/scalajs/nodejs/process/Process.scala b/app/current/src/main/scala/io/scalajs/nodejs/process/Process.scala index ecc4a52c2..f697fd312 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/process/Process.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/process/Process.scala @@ -273,7 +273,6 @@ trait Process extends IEventEmitter { */ def initgroups(user: String | Int, extra_group: String | Int): js.Array[Int] = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def hasUncaughtExceptionCaptureCallback(): Boolean = js.native /** @@ -365,7 +364,6 @@ trait Process extends IEventEmitter { */ def setuid(id: String | Int): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def setUncaughtExceptionCaptureCallback(callback: js.Function = js.native): Unit = js.native /** @@ -436,20 +434,13 @@ trait ComponentVersion extends js.Object { var icu: String = js.native var unicode: String = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) - var v8: String = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) - var brotli: String = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) + var v8: String = js.native + var brotli: String = js.native var nghttp2: String = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) - var napi: String = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) - var llhttp: String = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) - var cldr: String = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) - var tz: String = js.native + var napi: String = js.native + var llhttp: String = js.native + var cldr: String = js.native + var tz: String = js.native } /** @@ -490,7 +481,6 @@ class WarningOptions( @js.native trait HrTime extends js.Function1[js.Array[Int], js.Array[Int]] with js.Function0[js.Array[Int]] { // TODO: js.BigInt - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def bigint(): js.Any = js.native } diff --git a/app/current/src/main/scala/io/scalajs/nodejs/process/package.scala b/app/current/src/main/scala/io/scalajs/nodejs/process/package.scala index bf257c6a7..3323615be 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/process/package.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/process/package.scala @@ -81,7 +81,6 @@ package object process { def onMessage(listener: (js.Any, js.UndefOr[net.Server | net.Socket]) => Any): Process = process.on("message", listener) - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def onMultipleResolves[T](listener: (String, js.Promise[T], js.Any) => Any): Process = process.on("multipleResolves", listener) diff --git a/app/current/src/main/scala/io/scalajs/nodejs/repl/REPLServer.scala b/app/current/src/main/scala/io/scalajs/nodejs/repl/REPLServer.scala index 19f4ffc9b..59a9d9f2e 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/repl/REPLServer.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/repl/REPLServer.scala @@ -18,7 +18,6 @@ trait REPLServer extends IEventEmitter with Interface { */ val context: REPLContext = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def clearBufferedCommand(): Unit = js.native /** diff --git a/app/current/src/main/scala/io/scalajs/nodejs/stream/Stream.scala b/app/current/src/main/scala/io/scalajs/nodejs/stream/Stream.scala index ee34d14e6..1be6ee075 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/stream/Stream.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/stream/Stream.scala @@ -15,21 +15,13 @@ import scala.scalajs.js.typedarray.Uint8Array @js.native @JSImport("stream", JSImport.Namespace) object Stream extends js.Object { - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def finished(stream: Stream, options: FinishedOptions, callback: ErrorCallback): Wait = js.native + def finished(stream: Stream, callback: ErrorCallback): Wait = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) - def finished(stream: Stream, callback: ErrorCallback): Wait = js.native - - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) - def pipeline(a: Stream, b: Stream, callback: ErrorCallback): Wait = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) - def pipeline(a: Stream, b: Stream, c: Stream, callback: ErrorCallback): Wait = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) - def pipeline(a: Stream, b: Stream, c: Stream, d: Stream, callback: ErrorCallback): Wait = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) + def pipeline(a: Stream, b: Stream, callback: ErrorCallback): Wait = js.native + def pipeline(a: Stream, b: Stream, c: Stream, callback: ErrorCallback): Wait = js.native + def pipeline(a: Stream, b: Stream, c: Stream, d: Stream, callback: ErrorCallback): Wait = js.native def pipeline(a: Stream, b: Stream, c: Stream, d: Stream, e: Stream, callback: ErrorCallback): Wait = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def pipeline(a: Stream, b: Stream, c: Stream, d: Stream, e: Stream, f: Stream, callback: ErrorCallback): Wait = js.native } @@ -173,13 +165,10 @@ sealed trait IReadable extends LegacyStream { @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def readableEnded: Boolean = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def readableFlowing: Boolean = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def readableHighWaterMark: Double = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def readableLength: Int = js.native @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) @@ -404,10 +393,8 @@ sealed trait IWritable extends LegacyStream { @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def writable: Boolean = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def writableHighWaterMark: Double = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def writableLength: Int = js.native @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) diff --git a/app/current/src/main/scala/io/scalajs/nodejs/stream/package.scala b/app/current/src/main/scala/io/scalajs/nodejs/stream/package.scala index 3cf024297..7c9f28b17 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/stream/package.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/stream/package.scala @@ -1,7 +1,5 @@ package io.scalajs.nodejs -import com.thoughtworks.enableIf - import scala.scalajs.js import scala.scalajs.js.| @@ -12,7 +10,6 @@ package object stream { type Wait = js.Function0[js.Promise[Unit]] implicit final class StreamModuleExtension(private val stream: Stream.type) extends AnyVal { - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def pipelineFromSeq(streams: Seq[Stream], errorCallback: ErrorCallback): Wait = { streams match { case Seq(a, b) => stream.pipeline(a, b, errorCallback) diff --git a/app/current/src/main/scala/io/scalajs/nodejs/timers/Immediate.scala b/app/current/src/main/scala/io/scalajs/nodejs/timers/Immediate.scala index 77847e299..0b392757a 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/timers/Immediate.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/timers/Immediate.scala @@ -15,10 +15,8 @@ trait Immediate extends js.Object { @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def hasRef(): Boolean = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def ref(): Immediate = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def unref(): Immediate = js.native } diff --git a/app/current/src/main/scala/io/scalajs/nodejs/timers/Timeout.scala b/app/current/src/main/scala/io/scalajs/nodejs/timers/Timeout.scala index 52594cc31..00b57fb3b 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/timers/Timeout.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/timers/Timeout.scala @@ -19,7 +19,6 @@ trait Timeout extends js.Object { @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def hasRef(): Boolean = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def refresh(): Timeout = js.native def ref(): Timeout = js.native diff --git a/app/current/src/main/scala/io/scalajs/nodejs/tls/TLSSocket.scala b/app/current/src/main/scala/io/scalajs/nodejs/tls/TLSSocket.scala index 42eeb45cf..456e3b497 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/tls/TLSSocket.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/tls/TLSSocket.scala @@ -44,7 +44,6 @@ class TLSSocket(socket: stream.IDuplex, options: TLSSocketOptions = js.native) e */ def getPeerCertificate(detailed: String): TLSCertificate = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def getPeerFinished(): js.UndefOr[Buffer] = js.native /** diff --git a/app/current/src/main/scala/io/scalajs/nodejs/tty/WriteStream.scala b/app/current/src/main/scala/io/scalajs/nodejs/tty/WriteStream.scala index abc301255..d088259c6 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/tty/WriteStream.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/tty/WriteStream.scala @@ -43,7 +43,6 @@ class WriteStream(fd: FileDescriptor) extends net.Socket { @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def cursorTo(x: Int, y: Int, callback: js.Function): Boolean = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def getColorDepth(env: io.scalajs.nodejs.process.Environment = js.native): Int = js.native def getWindowSize(): js.Tuple2[Int, Int] = js.native diff --git a/app/current/src/main/scala/io/scalajs/nodejs/url/URL.scala b/app/current/src/main/scala/io/scalajs/nodejs/url/URL.scala index 2d3ffdf10..f08093aa8 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/url/URL.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/url/URL.scala @@ -1,7 +1,6 @@ package io.scalajs.nodejs package url -import com.thoughtworks.enableIf import io.scalajs.nodejs.events.IEventEmitter import scala.scalajs.js @@ -170,9 +169,7 @@ object URL extends IEventEmitter { */ def domainToUnicode(domain: String): String = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def fileURLToPath(url: URL | String): String = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def pathToFileURL(url: String): URL = js.native } diff --git a/app/current/src/main/scala/io/scalajs/nodejs/util/Util.scala b/app/current/src/main/scala/io/scalajs/nodejs/util/Util.scala index e4db081b8..90f76f6b2 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/util/Util.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/util/Util.scala @@ -1,7 +1,5 @@ package io.scalajs.nodejs.util -import com.thoughtworks.{enableIf, enableMembersIf} - import scala.scalajs.js import scala.scalajs.js.annotation.JSImport @@ -37,10 +35,8 @@ trait Util extends js.Object { */ def format(format: String, args: js.Any*): String = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def formatWithOptions(inspectOptions: InspectOptions, format: String, args: js.Any*): String = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def getSystemErrorName(err: Int): String = js.native /** @@ -58,10 +54,8 @@ trait Util extends js.Object { val promisify: PromisifyObject = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) val types: UtilTypes = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def isDeepStrictEqual(val1: js.Any, val2: js.Any): Boolean = js.native } @@ -77,7 +71,6 @@ trait InspectObject extends js.Function2[js.Any, InspectOptions, String] with js var defaultOptions: InspectOptions = js.native var styles: js.Dictionary[String] = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) val custom: js.Symbol = js.native } @@ -86,7 +79,6 @@ trait PromisifyObject extends js.Function1[js.Function, js.Function] { val custom: js.Symbol = js.native } -@enableMembersIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) @js.native trait UtilTypes extends js.Object { def isAnyArrayBuffer(value: js.Any): Boolean = js.native diff --git a/app/current/src/main/scala/io/scalajs/nodejs/vm/Script.scala b/app/current/src/main/scala/io/scalajs/nodejs/vm/Script.scala index 08790e594..f48687b43 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/vm/Script.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/vm/Script.scala @@ -1,7 +1,5 @@ package io.scalajs.nodejs.vm -import com.thoughtworks.enableIf - import scala.scalajs.js import scala.scalajs.js.annotation.JSImport import scala.scalajs.js.typedarray.{DataView, Uint8Array} @@ -16,7 +14,6 @@ class Script private[this] () extends js.Object { def this(code: String, options: ScriptOptions = js.native) = this() def this(code: String, filename: String) = this() - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def createCachedData(): io.scalajs.nodejs.buffer.Buffer = js.native /** diff --git a/app/current/src/main/scala/io/scalajs/nodejs/vm/VM.scala b/app/current/src/main/scala/io/scalajs/nodejs/vm/VM.scala index ba7eb11b9..ad7538b76 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/vm/VM.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/vm/VM.scala @@ -1,7 +1,5 @@ package io.scalajs.nodejs.vm -import com.thoughtworks.enableIf - import scala.scalajs.js import scala.scalajs.js.annotation.JSImport import scala.scalajs.js.typedarray.{DataView, Uint8Array} @@ -13,13 +11,10 @@ import scala.scalajs.js.| */ @js.native trait VM extends js.Object { - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def compileFunction(code: String, params: js.Array[String], options: CompileFunctionOptions = js.native): js.Function = js.native - - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) - def compileFunction(code: String): js.Function = js.native + def compileFunction(code: String): js.Function = js.native /** * If given a sandbox object, the vm.createContext() method will diff --git a/app/current/src/main/scala/io/scalajs/nodejs/worker_threads/MessageChannel.scala b/app/current/src/main/scala/io/scalajs/nodejs/worker_threads/MessageChannel.scala index fcdb03f09..76277b234 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/worker_threads/MessageChannel.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/worker_threads/MessageChannel.scala @@ -1,11 +1,8 @@ package io.scalajs.nodejs.worker_threads -import com.thoughtworks.enableMembersIf - import scala.scalajs.js import scala.scalajs.js.annotation.JSImport -@enableMembersIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) @js.native @JSImport("worker_threads", "MessageChannel") class MessageChannel extends js.Object { diff --git a/app/current/src/main/scala/io/scalajs/nodejs/worker_threads/MessagePort.scala b/app/current/src/main/scala/io/scalajs/nodejs/worker_threads/MessagePort.scala index d7f894821..3a9c42ef8 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/worker_threads/MessagePort.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/worker_threads/MessagePort.scala @@ -1,12 +1,10 @@ package io.scalajs.nodejs.worker_threads -import com.thoughtworks.enableMembersIf import io.scalajs.nodejs.events.IEventEmitter import scala.scalajs.js import scala.scalajs.js.annotation.JSImport -@enableMembersIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) @js.native @JSImport("worker_threads", "MessageChannel") class MessagePort extends IEventEmitter with MessagePoster { diff --git a/app/current/src/main/scala/io/scalajs/nodejs/worker_threads/MessagePoster.scala b/app/current/src/main/scala/io/scalajs/nodejs/worker_threads/MessagePoster.scala index c3a4019ef..20a5508fb 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/worker_threads/MessagePoster.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/worker_threads/MessagePoster.scala @@ -1,10 +1,7 @@ package io.scalajs.nodejs.worker_threads -import com.thoughtworks.enableMembersIf - import scala.scalajs.js -@enableMembersIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) @js.native trait MessagePoster extends js.Object { def postMessage(value: js.Any): Unit = js.native diff --git a/app/current/src/main/scala/io/scalajs/nodejs/worker_threads/Worker.scala b/app/current/src/main/scala/io/scalajs/nodejs/worker_threads/Worker.scala index 521b73fde..386f5b0bf 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/worker_threads/Worker.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/worker_threads/Worker.scala @@ -1,11 +1,8 @@ package io.scalajs.nodejs.worker_threads -import com.thoughtworks.enableMembersIf - import scala.scalajs.js import scala.scalajs.js.annotation.JSImport -@enableMembersIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) @js.native @JSImport("worker_threads", "Worker") class Worker(filename: String, workerOptions: WorkerOptions = js.native) extends js.Object with MessagePoster { diff --git a/app/current/src/main/scala/io/scalajs/nodejs/worker_threads/WorkerThreads.scala b/app/current/src/main/scala/io/scalajs/nodejs/worker_threads/WorkerThreads.scala index b9f0231d1..be640b0ac 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/worker_threads/WorkerThreads.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/worker_threads/WorkerThreads.scala @@ -7,19 +7,14 @@ import scala.scalajs.js.annotation.JSImport @js.native trait WorkerThreads extends js.Object { - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def isMainThread: Boolean = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def parentPort: js.|[MessagePort, Null] = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def SHARE_ENV: js.Symbol = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def threadId: Int = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs10) def workerData: js.Any = js.native @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) diff --git a/core/src/main/scala/io/scalajs/nodejs/internal/CompilerSwitches.scala b/core/src/main/scala/io/scalajs/nodejs/internal/CompilerSwitches.scala index 4eda1f6da..e389ae2e3 100644 --- a/core/src/main/scala/io/scalajs/nodejs/internal/CompilerSwitches.scala +++ b/core/src/main/scala/io/scalajs/nodejs/internal/CompilerSwitches.scala @@ -10,12 +10,6 @@ object CompilerSwitches { predicate(major.toInt, minor.toInt, patch.toInt) } - final val isNodeJs8 = (c: whitebox.Context) => c.settings.exists(compare((major, _, _) => major == 8)) - final val gteNodeJs8 = (c: whitebox.Context) => c.settings.exists(compare((major, _, _) => major >= 8)) - - final val isNodeJs10 = (c: whitebox.Context) => c.settings.exists(compare((major, _, _) => major == 10)) - final val gteNodeJs10 = (c: whitebox.Context) => c.settings.exists(compare((major, _, _) => major >= 10)) - final val isNodeJs12 = (c: whitebox.Context) => c.settings.exists(compare((major, _, _) => major == 12)) final val gteNodeJs12 = (c: whitebox.Context) => c.settings.exists(compare((major, _, _) => major >= 12)) } From 41da0596858d2bf810f7a417ac2aea4ae1d83b89 Mon Sep 17 00:00:00 2001 From: exoego Date: Thu, 2 Jan 2020 09:53:04 +0900 Subject: [PATCH 4/4] Drop node.js from Travis job --- .travis.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6379041d3..47b3aa167 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ env: - TRAVIS_NODE_VERSION="12.10.0" JOB_NAME="test" script: - - sbt ++$TRAVIS_SCALA_VERSION nodejs_v8/test nodejs_v10/test current/test + - sbt ++$TRAVIS_SCALA_VERSION test matrix: include: @@ -21,14 +21,10 @@ matrix: jdk: openjdk11 env: TRAVIS_NODE_VERSION="12.14.0" JOB_NAME="format and doc" script: sbt ++$TRAVIS_SCALA_VERSION scalafmtSbtCheck scalafmtCheck test:scalafmtCheck current/doc core/doc - - scala: 2.13.1 - jdk: openjdk11 - env: TRAVIS_NODE_VERSION="8.17.0" JOB_NAME="test" - script: sbt ++$TRAVIS_SCALA_VERSION nodejs_v8/test - scala: 2.13.1 jdk: openjdk11 env: TRAVIS_NODE_VERSION="10.18.0" JOB_NAME="test" - script: sbt ++$TRAVIS_SCALA_VERSION nodejs_v8/test nodejs_v10/test + script: sbt ++$TRAVIS_SCALA_VERSION nodejs_v10/test install: - rm -rf ~/.nvm &&