[sprout] Add copyright headers etc
Mofei Zhang committed
Aug 17, 2023 at 11:03 UTC
28688ade9f1ce1c2ad435b7ae8951073445b58d7
3 files changed
+59
-46
compiler/forget/packages/sprout/src/main.ts
+45
-46
@@ -1,53 +1,52 @@
1
-require("./runner.js");
2
-// /**
3
-// * Copyright (c) Meta Platforms, Inc. and affiliates.
4
-// *
5
-// * This source code is licensed under the MIT license found in the
6
-// * LICENSE file in the root directory of this source tree.
7
-// */
1
+/**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
9
-// import { fork } from "child_process";
10
-// import invariant from "invariant";
11
-// import process from "process";
12
-// import * as readline from "readline";
13
-// import { hideBin } from "yargs/helpers";
8
+import { fork } from "child_process";
9
+import invariant from "invariant";
10
+import process from "process";
11
+import * as readline from "readline";
12
+import { hideBin } from "yargs/helpers";
13
15
-// readline.emitKeypressEvents(process.stdin);
14
+readline.emitKeypressEvents(process.stdin);
15
17
-// if (process.stdin.isTTY) {
18
-// process.stdin.setRawMode(true);
19
-// }
16
+if (process.stdin.isTTY) {
17
+ process.stdin.setRawMode(true);
18
+}
19
21
-// process.stdin.on("keypress", function (_, key) {
22
-// if (key && key.name === "c" && key.ctrl) {
23
-// // handle sigint
24
-// if (childProc) {
25
-// console.log("Interrupted!!");
26
-// childProc.kill("SIGINT");
27
-// childProc.unref();
28
-// process.exit(-1);
29
-// }
30
-// }
31
-// });
20
+process.stdin.on("keypress", function (_, key) {
21
+ if (key && key.name === "c" && key.ctrl) {
22
+ // handle sigint
23
+ if (childProc) {
24
+ console.log("Interrupted!!");
25
+ childProc.kill("SIGINT");
26
+ childProc.unref();
27
+ process.exit(-1);
28
+ }
29
+ }
30
+});
31
33
-// const childProc = fork(require.resolve("./runner.js"), hideBin(process.argv), {
34
-// // for some reason, keypress events aren't sent to handlers in both processes
35
-// // when we `inherit` stdin.
36
-// // pipe stdout and stderr so we can silence child process after parent exits
37
-// stdio: ["pipe", "pipe", "pipe", "ipc"],
38
-// // forward existing env variables, like `NODE_OPTIONS` which VSCode uses to attach
39
-// // its debugger
40
-// env: { ...process.env, FORCE_COLOR: "true" },
41
-// });
32
+const childProc = fork(require.resolve("./runner.js"), hideBin(process.argv), {
33
+ // for some reason, keypress events aren't sent to handlers in both processes
34
+ // when we `inherit` stdin.
35
+ // pipe stdout and stderr so we can silence child process after parent exits
36
+ stdio: ["pipe", "pipe", "pipe", "ipc"],
37
+ // forward existing env variables, like `NODE_OPTIONS` which VSCode uses to attach
38
+ // its debugger
39
+ env: { ...process.env, FORCE_COLOR: "true" },
40
+});
41
43
-// invariant(
44
-// childProc.stdin && childProc.stdout && childProc.stderr,
45
-// "Expected forked process to have piped stdio"
46
-// );
47
-// process.stdin.pipe(childProc.stdin);
48
-// childProc.stdout.pipe(process.stdout);
49
-// childProc.stderr.pipe(process.stderr);
42
+invariant(
43
+ childProc.stdin && childProc.stdout && childProc.stderr,
44
+ "Expected forked process to have piped stdio"
45
+);
46
+process.stdin.pipe(childProc.stdin);
47
+childProc.stdout.pipe(process.stdout);
48
+childProc.stderr.pipe(process.stderr);
49
51
-// childProc.on("exit", (code) => {
52
-// process.exit(code ?? -1);
53
-// });
50
+childProc.on("exit", (code) => {
51
+ process.exit(code ?? -1);
52
+});
compiler/forget/packages/sprout/src/runner-evaluator.ts
+7
@@ -1,3 +1,10 @@
1
+/**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
// tslint:disable:no-unused-variable */
9
import { JSDOM } from "jsdom";
10
const React = require("react");
compiler/forget/packages/sprout/src/runner-worker.ts
+7
@@ -1,3 +1,10 @@
1
+/**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
import type { runReactForgetBabelPlugin as RunReactForgetBabelPlugin } from "babel-plugin-react-forget/src/Babel/RunReactForgetBabelPlugin";
9
import {
10
COMPILER_PATH,