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

Commit 537e387

Browse files
authored
Merge pull request #180 from exoego/os-constants
Implement OS.constants
2 parents 6f06436 + 04d7e0a commit 537e387

File tree

4 files changed

+171
-4
lines changed

4 files changed

+171
-4
lines changed

app/current/src/main/scala/io/scalajs/nodejs/child_process/package.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ package object child_process {
3333
): Future[(Output, Output)] = {
3434
promiseWithError2[nodejs.Error, Output, Output](cp.execFile(file, args.orNull, options.orNull, _))
3535
}
36-
37-
// TODO: spawn, fork
3836
}
3937

4038
implicit final class ChildProcessExtensions(private val cp: ChildProcess) extends AnyVal {

app/current/src/main/scala/io/scalajs/nodejs/os/OS.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ trait OS extends js.Object {
1919
* are described in OS Constants.
2020
* @see https://nodejs.org/api/os.html#os_os_constants_1
2121
*/
22-
// TODO: Implement as object
23-
def constants: js.Dictionary[js.Any] = js.native
22+
def constants: OSConstants = js.native
2423

2524
/**
2625
* A constant defining the appropriate End-of-line marker for the operating system.
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
package io.scalajs.nodejs.os
2+
3+
import scala.scalajs.js
4+
import scala.scalajs.js.annotation.JSBracketAccess
5+
6+
@js.native
7+
trait OSConstants extends js.Object {
8+
@deprecated("Use named members", "v0.10.0")
9+
@JSBracketAccess
10+
def apply(key: String): js.Any = js.native
11+
12+
val UV_UDP_REUSEADDR: Int = js.native
13+
val dlopen: OSDlopenConstants = js.native
14+
val errno: OSErrnoConstants = js.native
15+
val signals: OSSignalsConstants = js.native
16+
val priority: OSPriorityConstants = js.native
17+
}
18+
19+
@js.native
20+
trait OSDlopenConstants extends js.Object {
21+
val RTLD_LAZY: Int = js.native
22+
val RTLD_NOW: Int = js.native
23+
val RTLD_GLOBAL: Int = js.native
24+
val RTLD_LOCAL: Int = js.native
25+
val RTLD_DEEPBIND: Int = js.native
26+
}
27+
28+
@js.native
29+
trait OSErrnoConstants extends js.Object {
30+
val E2BIG: Int = js.native
31+
val EACCES: Int = js.native
32+
val EADDRINUSE: Int = js.native
33+
val EADDRNOTAVAIL: Int = js.native
34+
val EAFNOSUPPORT: Int = js.native
35+
val EAGAIN: Int = js.native
36+
val EALREADY: Int = js.native
37+
val EBADF: Int = js.native
38+
val EBADMSG: Int = js.native
39+
val EBUSY: Int = js.native
40+
val ECANCELED: Int = js.native
41+
val ECHILD: Int = js.native
42+
val ECONNABORTED: Int = js.native
43+
val ECONNREFUSED: Int = js.native
44+
val ECONNRESET: Int = js.native
45+
val EDEADLK: Int = js.native
46+
val EDESTADDRREQ: Int = js.native
47+
val EDOM: Int = js.native
48+
val EDQUOT: Int = js.native
49+
val EEXIST: Int = js.native
50+
val EFAULT: Int = js.native
51+
val EFBIG: Int = js.native
52+
val EHOSTUNREACH: Int = js.native
53+
val EIDRM: Int = js.native
54+
val EILSEQ: Int = js.native
55+
val EINPROGRESS: Int = js.native
56+
val EINTR: Int = js.native
57+
val EINVAL: Int = js.native
58+
val EIO: Int = js.native
59+
val EISCONN: Int = js.native
60+
val EISDIR: Int = js.native
61+
val ELOOP: Int = js.native
62+
val EMFILE: Int = js.native
63+
val EMLINK: Int = js.native
64+
val EMSGSIZE: Int = js.native
65+
val EMULTIHOP: Int = js.native
66+
val ENAMETOOLONG: Int = js.native
67+
val ENETDOWN: Int = js.native
68+
val ENETRESET: Int = js.native
69+
val ENETUNREACH: Int = js.native
70+
val ENFILE: Int = js.native
71+
val ENOBUFS: Int = js.native
72+
val ENODATA: Int = js.native
73+
val ENODEV: Int = js.native
74+
val ENOENT: Int = js.native
75+
val ENOEXEC: Int = js.native
76+
val ENOLCK: Int = js.native
77+
val ENOLINK: Int = js.native
78+
val ENOMEM: Int = js.native
79+
val ENOMSG: Int = js.native
80+
val ENOPROTOOPT: Int = js.native
81+
val ENOSPC: Int = js.native
82+
val ENOSR: Int = js.native
83+
val ENOSTR: Int = js.native
84+
val ENOSYS: Int = js.native
85+
val ENOTCONN: Int = js.native
86+
val ENOTDIR: Int = js.native
87+
val ENOTEMPTY: Int = js.native
88+
val ENOTSOCK: Int = js.native
89+
val ENOTSUP: Int = js.native
90+
val ENOTTY: Int = js.native
91+
val ENXIO: Int = js.native
92+
val EOPNOTSUPP: Int = js.native
93+
val EOVERFLOW: Int = js.native
94+
val EPERM: Int = js.native
95+
val EPIPE: Int = js.native
96+
val EPROTO: Int = js.native
97+
val EPROTONOSUPPORT: Int = js.native
98+
val EPROTOTYPE: Int = js.native
99+
val ERANGE: Int = js.native
100+
val EROFS: Int = js.native
101+
val ESPIPE: Int = js.native
102+
val ESRCH: Int = js.native
103+
val ESTALE: Int = js.native
104+
val ETIME: Int = js.native
105+
val ETIMEDOUT: Int = js.native
106+
val ETXTBSY: Int = js.native
107+
val EWOULDBLOCK: Int = js.native
108+
val EXDEV: Int = js.native
109+
}
110+
111+
@js.native
112+
trait OSSignalsConstants extends js.Object {
113+
val SIGHUP: Int = js.native
114+
val SIGINT: Int = js.native
115+
val SIGQUIT: Int = js.native
116+
val SIGILL: Int = js.native
117+
val SIGTRAP: Int = js.native
118+
val SIGABRT: Int = js.native
119+
val SIGIOT: Int = js.native
120+
val SIGBUS: Int = js.native
121+
val SIGFPE: Int = js.native
122+
val SIGKILL: Int = js.native
123+
val SIGUSR1: Int = js.native
124+
val SIGSEGV: Int = js.native
125+
val SIGUSR2: Int = js.native
126+
val SIGPIPE: Int = js.native
127+
val SIGALRM: Int = js.native
128+
val SIGTERM: Int = js.native
129+
val SIGCHLD: Int = js.native
130+
val SIGSTKFLT: Int = js.native
131+
val SIGCONT: Int = js.native
132+
val SIGSTOP: Int = js.native
133+
val SIGTSTP: Int = js.native
134+
val SIGTTIN: Int = js.native
135+
val SIGTTOU: Int = js.native
136+
val SIGURG: Int = js.native
137+
val SIGXCPU: Int = js.native
138+
val SIGXFSZ: Int = js.native
139+
val SIGVTALRM: Int = js.native
140+
val SIGPROF: Int = js.native
141+
val SIGWINCH: Int = js.native
142+
val SIGIO: Int = js.native
143+
val SIGPOLL: Int = js.native
144+
val SIGPWR: Int = js.native
145+
val SIGSYS: Int = js.native
146+
val SIGUNUSED: Int = js.native
147+
}
148+
149+
@js.native
150+
trait OSPriorityConstants extends js.Object {
151+
val PRIORITY_LOW: Int = js.native
152+
val PRIORITY_BELOW_NORMAL: Int = js.native
153+
val PRIORITY_NORMAL: Int = js.native
154+
val PRIORITY_ABOVE_NORMAL: Int = js.native
155+
val PRIORITY_HIGH: Int = js.native
156+
val PRIORITY_HIGHEST: Int = js.native
157+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package io.scalajs.nodejs.os
2+
3+
import org.scalatest.funsuite.AnyFunSuite
4+
5+
class OSTest extends AnyFunSuite {
6+
test("constants") {
7+
assert(OS.constants.dlopen.RTLD_LOCAL.isInstanceOf[Int])
8+
assert(OS.constants.errno.E2BIG.isInstanceOf[Int])
9+
assert(OS.constants.priority.PRIORITY_HIGHEST.isInstanceOf[Int])
10+
assert(OS.constants.signals.SIGABRT.isInstanceOf[Int])
11+
assert(OS.constants.UV_UDP_REUSEADDR.isInstanceOf[Int])
12+
}
13+
}

0 commit comments

Comments
 (0)