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

Commit f8f77df

Browse files
authored
Merge pull request #234 from exoego/more-factory
[BREAKING] Use Factory macro for optimization and maintainability
2 parents 6ff412d + 0625032 commit f8f77df

File tree

76 files changed

+1479
-1116
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+1479
-1116
lines changed

app/current/src/main/scala/io/scalajs/nodejs/Require.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package io.scalajs.nodejs
22

3+
import _root_.net.exoego.scalajs.types.util.Factory
4+
35
import scala.scalajs.js
46
import scala.scalajs.js.annotation.JSGlobal
57

@@ -23,6 +25,7 @@ trait RequireResolver extends js.Object {
2325
def paths(requiest: String): js.Array[String] = js.native
2426
}
2527

26-
class ResolveOptions(
27-
var paths: js.UndefOr[js.Array[String]] = js.undefined
28-
) extends js.Object
28+
@Factory
29+
trait ResolveOptions extends js.Object {
30+
var paths: js.UndefOr[js.Array[String]] = js.undefined
31+
}
Lines changed: 57 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.scalajs.nodejs.child_process
22

33
import io.scalajs.nodejs.{GID, UID}
4+
import net.exoego.scalajs.types.util.Factory
45

56
import scala.scalajs.js
67
import scala.scalajs.js.|
@@ -10,35 +11,60 @@ import scala.scalajs.js.|
1011
*
1112
* Note: Never pass unsanitized user input to this function. Any input containing shell meta-characters
1213
* may be used to trigger arbitrary command execution.
13-
*
14-
* @param cwd Current working directory of the child process
15-
* @param input The value which will be passed as stdin to the spawned process.
16-
* Supplying this value will override stdio[0].
17-
* @param stdio Child's stdio configuration. stderr by default will be output to the parent process' stderr unless stdio is specified.
18-
* Default: 'pipe'.
19-
* @param env Environment key-value pairs
20-
* @param encoding (Default: 'utf8')
21-
* @param shell Shell to execute the command with (Default: '/bin/sh' on UNIX, 'cmd.exe' on Windows,
22-
* The shell should understand the -c switch on UNIX or /d /s /c on Windows. On Windows, command line
23-
* parsing should be compatible with cmd.exe.)
24-
* @param timeout (Default: 0)
25-
* @param maxBuffer largest amount of data (in bytes) allowed on stdout or stderr - if exceeded child process
26-
* is killed (Default: 200*1024)
27-
* @param killSignal (Default: 'SIGTERM')
28-
* @param uid Sets the user identity of the process. (See setuid(2).)
29-
* @param gid Sets the group identity of the process. (See setgid(2).)
30-
* @param windowsHide Hide the subprocess console window that would normally be created on Windows systems. Default: `false`.
3114
*/
32-
class ExecFileSyncOptions(var cwd: js.UndefOr[String] = js.undefined,
33-
var input: js.UndefOr[Input] = js.undefined,
34-
var stdio: js.UndefOr[StdIo] = js.undefined,
35-
var env: js.UndefOr[js.Object] = js.undefined,
36-
var encoding: js.UndefOr[String] = js.undefined,
37-
var shell: js.UndefOr[Boolean | String] = js.undefined,
38-
var timeout: js.UndefOr[Int] = js.undefined,
39-
var maxBuffer: js.UndefOr[Int] = js.undefined,
40-
var killSignal: js.UndefOr[KillSignal] = js.undefined,
41-
var uid: js.UndefOr[UID] = js.undefined,
42-
var gid: js.UndefOr[GID] = js.undefined,
43-
var windowsHide: js.UndefOr[Boolean] = js.undefined
44-
) extends js.Object
15+
@Factory
16+
trait ExecFileSyncOptions extends js.Object {
17+
18+
/** Current working directory of the child process
19+
*/
20+
var cwd: js.UndefOr[String] = js.undefined
21+
22+
/** The value which will be passed as stdin to the spawned process.
23+
* Supplying this value will override stdio[0].
24+
*/
25+
var input: js.UndefOr[Input] = js.undefined
26+
27+
/** Child's stdio configuration. stderr by default will be output to the parent process' stderr unless stdio is specified.
28+
* Default: 'pipe'.
29+
*/
30+
var stdio: js.UndefOr[StdIo] = js.undefined
31+
32+
/** Environment key-value pairs
33+
*
34+
*/
35+
var env: js.UndefOr[js.Object] = js.undefined
36+
37+
/** (Default: 'utf8')
38+
*/
39+
var encoding: js.UndefOr[String] = js.undefined
40+
41+
/** Shell to execute the command with (Default: '/bin/sh' on UNIX, 'cmd.exe' on Windows,
42+
* The shell should understand the -c switch on UNIX or /d /s /c on Windows. On Windows, command line parsing should be compatible with cmd.exe.)
43+
*/
44+
var shell: js.UndefOr[Boolean | String] = js.undefined
45+
46+
/** (Default: 0)
47+
*/
48+
var timeout: js.UndefOr[Int] = js.undefined
49+
50+
/** largest amount of data (in bytes) allowed on stdout or stderr - if exceeded child process is killed (Default: 200*1024)
51+
*/
52+
var maxBuffer: js.UndefOr[Int] = js.undefined
53+
54+
/** (Default: 'SIGTERM')
55+
*/
56+
var killSignal: js.UndefOr[KillSignal] = js.undefined
57+
58+
/** Sets the user identity of the process. (See setuid(2).)
59+
*/
60+
var uid: js.UndefOr[UID] = js.undefined
61+
62+
/** Sets the group identity of the process. (See setgid(2).)
63+
*/
64+
var gid: js.UndefOr[GID] = js.undefined
65+
66+
/** Hide the subprocess console window that would normally be created on Windows systems.
67+
* Default: `false`.
68+
*/
69+
var windowsHide: js.UndefOr[Boolean] = js.undefined
70+
}
Lines changed: 54 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package io.scalajs.nodejs
22
package child_process
33

4+
import _root_.net.exoego.scalajs.types.util.Factory
5+
46
import scala.scalajs.js
57
import scala.scalajs.js.|
68

@@ -9,31 +11,56 @@ import scala.scalajs.js.|
911
*
1012
* Note: Never pass unsanitized user input to this function. Any input containing shell meta-characters
1113
* may be used to trigger arbitrary command execution.
12-
* @param cwd Current working directory of the child process
13-
* @param env Environment key-value pairs
14-
* @param encoding (Default: 'utf8')
15-
* @param shell Shell to execute the command with (Default: '/bin/sh' on UNIX, 'cmd.exe' on Windows,
16-
* The shell should understand the -c switch on UNIX or /d /s /c on Windows. On Windows, command line
17-
* parsing should be compatible with cmd.exe.)
18-
* @param timeout (Default: 0)
19-
* @param maxBuffer largest amount of data (in bytes) allowed on stdout or stderr - if exceeded child process
20-
* is killed (Default: 200*1024)
21-
* @param killSignal (Default: 'SIGTERM')
22-
* @param uid Sets the user identity of the process. (See setuid(2).)
23-
* @param gid Sets the group identity of the process. (See setgid(2).)
24-
* @param windowsHide Hide the subprocess console window that would normally be created on Windows systems. Default: `false`.
25-
* @param windowsVerbatimArguments No quoting or escaping of arguments is done on Windows.
26-
* Ignored on Unix. This is set to true automatically when shell is specified and is CMD. Default: false.
2714
*/
28-
class ExecOptions(var cwd: js.UndefOr[String] = js.undefined,
29-
var env: js.UndefOr[js.Object] = js.undefined,
30-
var encoding: js.UndefOr[String] = js.undefined,
31-
var shell: js.UndefOr[Boolean | String] = js.undefined,
32-
var timeout: js.UndefOr[Int] = js.undefined,
33-
var maxBuffer: js.UndefOr[Int] = js.undefined,
34-
var killSignal: js.UndefOr[KillSignal] = js.undefined,
35-
var uid: js.UndefOr[UID] = js.undefined,
36-
var gid: js.UndefOr[GID] = js.undefined,
37-
var windowsHide: js.UndefOr[Boolean] = js.undefined,
38-
var windowsVerbatimArguments: js.UndefOr[Boolean] = js.undefined
39-
) extends js.Object
15+
@Factory
16+
trait ExecOptions extends js.Object {
17+
18+
/** Current working directory of the child process
19+
*/
20+
var cwd: js.UndefOr[String] = js.undefined
21+
22+
/** Environment key-value pairs
23+
*/
24+
var env: js.UndefOr[js.Object] = js.undefined
25+
26+
/** (Default: 'utf8')
27+
*/
28+
var encoding: js.UndefOr[String] = js.undefined
29+
30+
/** Shell to execute the command with (Default: '/bin/sh' on UNIX, 'cmd.exe' on Windows,
31+
* The shell should understand the -c switch on UNIX or /d /s /c on Windows. On Windows, command line
32+
* parsing should be compatible with cmd.exe.)
33+
*/
34+
var shell: js.UndefOr[Boolean | String] = js.undefined
35+
36+
/** (Default: 0)
37+
*/
38+
var timeout: js.UndefOr[Int] = js.undefined
39+
40+
/** largest amount of data (in bytes) allowed on stdout or stderr - if exceeded child process
41+
* is killed (Default: 200*1024)
42+
*/
43+
var maxBuffer: js.UndefOr[Int] = js.undefined
44+
45+
/** (Default: 'SIGTERM')
46+
*/
47+
var killSignal: js.UndefOr[KillSignal] = js.undefined
48+
49+
/** Sets the user identity of the process. (See setuid(2).)
50+
*/
51+
var uid: js.UndefOr[UID] = js.undefined
52+
53+
/** Sets the group identity of the process. (See setgid(2).)
54+
*/
55+
var gid: js.UndefOr[GID] = js.undefined
56+
57+
/** Hide the subprocess console window that would normally be created on Windows systems.
58+
* Default: `false`.
59+
*/
60+
var windowsHide: js.UndefOr[Boolean] = js.undefined
61+
62+
/** No quoting or escaping of arguments is done on Windows.
63+
* Ignored on Unix. This is set to true automatically when shell is specified and is CMD. Default: false.
64+
*/
65+
var windowsVerbatimArguments: js.UndefOr[Boolean] = js.undefined
66+
}

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

Lines changed: 44 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,47 @@ package child_process
44
import scala.scalajs.js
55
import scala.scalajs.js.|
66

7-
/**
8-
* Fork Options
9-
* @param cwd Current working directory of the child process
10-
* @param detached Prepare child to run independently of its parent process
11-
* Specific behavior depends on the platform (see options.detached).
12-
* @param env Environment key-value pairs
13-
* @param execPath Executable used to create the child process
14-
* @param execArgv List of string arguments passed to the executable (Default: process.execArgv)
15-
* @param serialization
16-
* From Node.js v13.2.0, v12.16.0.
17-
* Specify the kind of serialization used for sending messages between processes.
18-
* Possible values are 'json' and 'advanced'. See Advanced Serialization for more details.
19-
* Default: 'json'.
20-
* @param silent If true, stdin, stdout, and stderr of the child will be piped to the parent,
21-
* otherwise they will be inherited from the parent, see the 'pipe' and 'inherit' options
22-
* for child_process.spawn()'s stdio for more details (Default: false)
23-
* @param stdio Supports the array version of child_process.spawn()'s stdio option. When this
24-
* option is provided, it overrides silent. The array must contain exactly one item with
25-
* value 'ipc' or an error will be thrown. For instance [0, 1, 2, 'ipc'].
26-
* @param uid Sets the user identity of the process. (See setuid(2).)
27-
* @param gid Sets the group identity of the process. (See setgid(2).)
28-
*/
29-
class ForkOptions(var cwd: js.UndefOr[String] = js.undefined,
30-
var detached: js.UndefOr[Boolean] = js.undefined,
31-
var env: js.UndefOr[js.Object] = js.undefined,
32-
var execPath: js.UndefOr[String] = js.undefined,
33-
var execArgv: js.UndefOr[Array[String]] = js.undefined,
34-
var serialization: js.UndefOr[String] = js.undefined,
35-
var silent: js.UndefOr[Boolean] = js.undefined,
36-
var stdio: js.UndefOr[String | Array[String]] = js.undefined,
37-
var uid: js.UndefOr[UID] = js.undefined,
38-
var gid: js.UndefOr[GID] = js.undefined
39-
) extends js.Object
7+
trait ForkOptions extends js.Object {
8+
9+
/** Current working directory of the child process */
10+
var cwd: js.UndefOr[String] = js.undefined
11+
12+
/** Prepare child to run independently of its parent process
13+
* Specific behavior depends on the platform (see options.detached).
14+
*/
15+
var detached: js.UndefOr[Boolean] = js.undefined
16+
17+
/** Environment key-value pairs */
18+
var env: js.UndefOr[js.Object] = js.undefined
19+
20+
/** Executable used to create the child process */
21+
var execPath: js.UndefOr[String] = js.undefined
22+
23+
/** List of string arguments passed to the executable (Default: process.execArgv) */
24+
var execArgv: js.UndefOr[Array[String]] = js.undefined
25+
26+
/** From Node.js v13.2.0, v12.16.0.
27+
* Specify the kind of serialization used for sending messages between processes.
28+
* Possible values are 'json' and 'advanced'. See Advanced Serialization for more details.
29+
* Default: 'json'.
30+
*/
31+
var serialization: js.UndefOr[String] = js.undefined
32+
33+
/** If true, stdin, stdout, and stderr of the child will be piped to the parent,
34+
* otherwise they will be inherited from the parent, see the 'pipe' and 'inherit' options
35+
* for child_process.spawn()'s stdio for more details (Default: false)
36+
*/
37+
var silent: js.UndefOr[Boolean] = js.undefined
38+
39+
/** Supports the array version of child_process.spawn()'s stdio option. When this
40+
* option is provided, it overrides silent. The array must contain exactly one item with
41+
* value 'ipc' or an error will be thrown. For instance [0, 1, 2, 'ipc'].
42+
*/
43+
var stdio: js.UndefOr[String | Array[String]] = js.undefined
44+
45+
/** Sets the user identity of the process. (See setuid(2).) */
46+
var uid: js.UndefOr[UID] = js.undefined
47+
48+
/** Sets the group identity of the process. (See setgid(2).) */
49+
var gid: js.UndefOr[GID] = js.undefined
50+
}
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package io.scalajs.nodejs.child_process
22

3+
import net.exoego.scalajs.types.util.Factory
4+
35
import scala.scalajs.js
46

5-
class SendOptions(
6-
var keepOpen: js.UndefOr[Boolean] = js.undefined
7-
) extends js.Object {}
7+
@Factory
8+
trait SendOptions extends js.Object {
9+
var keepOpen: js.UndefOr[Boolean] = js.undefined
10+
}

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

Lines changed: 43 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,46 @@ package io.scalajs.nodejs.child_process
33
import scala.scalajs.js
44
import scala.scalajs.js.|
55

6-
/**
7-
* Spawn Options
8-
*
9-
* @param cwd Current working directory of the child process
10-
* @param env Environment key-value pairs
11-
* @param argv0 Explicitly set the value of argv[0] sent to the child process.
12-
* This will be set to command if not specified.
13-
* @param stdio Child's stdio configuration. (See options.stdio)
14-
* @param detached Prepare child to run independently of its parent process.
15-
* Specific behavior depends on the platform, see options.detached)
16-
* @param uid Sets the user identity of the process. (See setuid(2).)
17-
* @param gid Sets the group identity of the process. (See setgid(2).)
18-
* @param shell If true, runs command inside of a shell.
19-
* Uses '/bin/sh' on UNIX, and 'cmd.exe' on Windows. A different shell can be specified as a string.
20-
* The shell should understand the -c switch on UNIX, or /d /s /c on Windows. Defaults to false (no shell).
21-
*/
22-
class SpawnOptions(
23-
var cwd: js.UndefOr[String] = js.undefined,
24-
var env: js.Any = js.undefined,
25-
var argv0: js.UndefOr[String] = js.undefined,
26-
var stdio: js.UndefOr[StdIo] = js.undefined,
27-
var detached: js.UndefOr[Boolean] = js.undefined,
28-
var uid: js.UndefOr[Int] = js.undefined,
29-
var gid: js.UndefOr[Int] = js.undefined,
30-
var shell: js.UndefOr[Boolean | String] = js.undefined,
31-
var windowsVerbatimArguments: js.UndefOr[Boolean] = js.undefined,
32-
var windowsHide: js.UndefOr[Boolean] = js.undefined
33-
) extends js.Object
6+
trait SpawnOptions extends js.Object {
7+
8+
/** Current working directory of the child process */
9+
var cwd: js.UndefOr[String] = js.undefined
10+
11+
/** Environment key-value pairs */
12+
var env: js.UndefOr[js.Object] = js.undefined
13+
14+
/** Explicitly set the value of argv[0] sent to the child process.
15+
* This will be set to command if not specified.
16+
*/
17+
var argv0: js.UndefOr[String] = js.undefined
18+
19+
/** Child's stdio configuration. (See options.stdio) */
20+
var stdio: js.UndefOr[StdIo] = js.undefined
21+
22+
/** Prepare child to run independently of its parent process.
23+
* Specific behavior depends on the platform, see options.detached)
24+
*/
25+
var detached: js.UndefOr[Boolean] = js.undefined
26+
27+
/** Sets the user identity of the process. (See setuid(2).) */
28+
var uid: js.UndefOr[Int] = js.undefined
29+
30+
/** Sets the group identity of the process. (See setgid(2).) */
31+
var gid: js.UndefOr[Int] = js.undefined
32+
33+
/** If true, runs command inside of a shell.
34+
* Uses '/bin/sh' on UNIX, and 'cmd.exe' on Windows. A different shell can be specified as a string.
35+
* The shell should understand the -c switch on UNIX, or /d /s /c on Windows. Defaults to false (no shell).
36+
*/
37+
var shell: js.UndefOr[Boolean | String] = js.undefined
38+
39+
/** No quoting or escaping of arguments is done on Windows.
40+
* Ignored on Unix. This is set to true automatically when shell is specified and is CMD. Default: false.
41+
*/
42+
var windowsVerbatimArguments: js.UndefOr[Boolean] = js.undefined
43+
44+
/** Hide the subprocess console window that would normally be created on Windows systems.
45+
* Default: `false`.
46+
*/
47+
var windowsHide: js.UndefOr[Boolean] = js.undefined
48+
}

0 commit comments

Comments
 (0)