๐
Node Start Script
js
const { exec } = require("child_process");const args = process.argv.slice(2);const deployment = args[0] || "dev";const DEPLOYMENT_CONFIGS = {dev: "dev",};const tempConfigPath = "public/config/config-temp.json";const remoteConfigPath = `https://${DEPLOYMENT_CONFIGS[deployment] || DEPLOYMENT_CONFIGS.dev}/config/config.json`;const commands = `mkdir -p public/config/ && curl -o ${tempConfigPath} ${remoteConfigPath}`;exec(commands, (error) => {const messagePrefix = `Download [${deployment}] remote config file`;if (error) {console.error(`${messagePrefix} failed`, error.message);return;}// eslint-disable-next-line no-consoleconsole.log(`${messagePrefix} successfully.`, remoteConfigPath);const start = exec("yarn react-scripts start");start.stdout.on("data", (data) => {console.log("stdout", data);// do whatever you want here with data});start.stderr.on("data", (data) => {console.error("stderr", data);});});
sh
#!/bin/bashCONFIG_PATH_DOMAIN=""TEMP_CONFIG_PATH="public/config/config-temp.json"case "$1" insbx) CONFIG_PATH_DOMAIN="sbx" ;;*) CONFIG_PATH_DOMAIN="test" ;;esacCONFIG_PATH="https://${CONFIG_PATH_DOMAIN}/config/config.json"echo "Download ${S1} Config ${CONFIG_PATH} successfully"mkdir -p public/config/ && curl -o ${TEMP_CONFIG_PATH} ${CONFIG_PATH}react-scripts start