Skip to content

Commit be65bd5

Browse files
committed
Use bufout instead of concurrently
1 parent c6a34c0 commit be65bd5

File tree

6 files changed

+70
-72
lines changed

6 files changed

+70
-72
lines changed

.github/workflows/check.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,3 @@ jobs:
134134
adb uninstall com.microsoft.reacttestapp || true
135135
# Build, install and run the app
136136
npm run test:android
137-
# Wait a bit for the sub-process to terminate, before terminating the emulator
138-
sleep 5

apps/test-app/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "react-native-node-api-test-app",
3+
"type": "commonjs",
34
"private": true,
45
"version": "0.1.0",
56
"scripts": {
@@ -8,8 +9,8 @@
89
"build:android": "react-native bundle --entry-file index.js --platform android --dev true --bundle-output dist/main.android.jsbundle --assets-dest dist/res",
910
"ios": "react-native run-ios --no-packager",
1011
"pod-install": "cd ios && pod install",
11-
"test:android": "mocha-remote --exit-on-error -- concurrently --kill-timeout 1000 npm:start npm:android",
12-
"test:ios": "mocha-remote --exit-on-error -- concurrently --kill-timeout 1000 npm:start npm:ios"
12+
"test:android": "mocha-remote --exit-on-error -- tsx ./scripts/run-tests.ts android",
13+
"test:ios": "mocha-remote --exit-on-error -- tsx ./scripts/run-tests.ts ios"
1314
},
1415
"dependencies": {
1516
"@babel/core": "^7.26.10",
@@ -23,7 +24,7 @@
2324
"@react-native/typescript-config": "0.79.0",
2425
"@rnx-kit/metro-config": "^2.0.1",
2526
"@types/react": "^19.0.0",
26-
"concurrently": "^9.1.2",
27+
"bufout": "^0.3.2",
2728
"ferric-example": "^0.1.0",
2829
"mocha": "^11.6.0",
2930
"mocha-remote-cli": "^1.13.1",

apps/test-app/scripts/run-tests.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import assert from "node:assert/strict";
2+
import path from "node:path";
3+
4+
import { spawn } from "bufout";
5+
6+
// Ideally, we would just use "concurrently" or "npm-run-all" to run these in parallel but:
7+
// - "concurrently" hangs the emulator action on Ubuntu
8+
// - "npm-run-all" shows symptoms of not closing metro when Mocha Remote sends a SIGTERM
9+
10+
const platform = process.argv[2];
11+
assert(
12+
platform === "android" || platform === "ios",
13+
"Platform must be 'android' or 'ios'"
14+
);
15+
16+
const cwd = path.resolve(__dirname, "..");
17+
const env = {
18+
...process.env,
19+
FORCE_COLOR: "1",
20+
};
21+
22+
const metro = spawn("npx", ["react-native", "start", "--no-interactive"], {
23+
cwd,
24+
stdio: "inherit",
25+
outputPrefix: "[metro] ",
26+
env,
27+
});
28+
29+
const build = spawn(
30+
"npx",
31+
[
32+
"react-native",
33+
`run-${platform}`,
34+
"--no-packager",
35+
...(platform === "android" ? ["--active-arch-only"] : []),
36+
],
37+
{
38+
cwd,
39+
stdio: "inherit",
40+
outputPrefix: `[${platform}] `,
41+
env,
42+
}
43+
);
44+
45+
Promise.all([metro, build]).catch(console.error);

apps/test-app/tsconfig.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
{
2-
"extends": "@react-native/typescript-config/tsconfig.json"
2+
"extends": "@react-native/typescript-config/tsconfig.json",
3+
"compilerOptions": {
4+
"types": ["react-native"]
5+
},
6+
"files": ["App.tsx", "index.ts"],
7+
"references": [{ "path": "./tsconfig.node-scripts.json" }]
38
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": "@tsconfig/node22/tsconfig.json",
3+
"compilerOptions": {
4+
"composite": true,
5+
"emitDeclarationOnly": true,
6+
"outDir": "dist",
7+
"rootDir": "scripts",
8+
"types": ["node", "bufout"]
9+
},
10+
"include": ["scripts/**/*.ts"],
11+
"exclude": []
12+
}

package-lock.json

Lines changed: 3 additions & 66 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)