Merge pull request 'write script to use env variables' (#100) from andy/start-script into master

Reviewed-on: railbird/railbird-mobile#100
This commit is contained in:
Ivan Malison 2024-02-06 21:09:27 -07:00
commit bbbcffcfcb
3 changed files with 18 additions and 2 deletions

View File

@ -7,8 +7,8 @@
"start:android": "expo start --android", "start:android": "expo start --android",
"start:ios": "expo start --ios", "start:ios": "expo start --ios",
"android": "expo run:android", "android": "expo run:android",
"android:dev": "NODE_ENV=development expo run:android", "android:dev": "node ./start.js development",
"android:prod": "NODE_ENV=production expo run:android", "android:test": "node ./start.js test",
"ios": "expo run:ios", "ios": "expo run:ios",
"ios:dev": "NODE_ENV=development expo run:ios", "ios:dev": "NODE_ENV=development expo run:ios",
"ios:prod": "NODE_ENV=production expo run:ios", "ios:prod": "NODE_ENV=production expo run:ios",

16
start.js Normal file
View File

@ -0,0 +1,16 @@
const { spawn } = require("child_process");
const envName = process.argv[2];
const expoStart = spawn("expo", ["start", "-c"]);
expoStart.stdout.on("data", (data) => {
if (data.toString().includes("Logs for your project will appear below")) {
expoStart.kill("SIGINT");
}
});
expoStart.on("close", () => {
const env = { ...process.env, NODE_ENV: envName };
spawn("expo", ["run:android"], { env, stdio: "inherit" });
});