So I am looking to create a script in the package.json that runs either start:dev or start:prod if ENV in the .env file is set to dev or prod and by default - if nothing is set start:dev should run.
I am unsure how to check environment variables inside a npm run script.
What I want
Something like:
if ENV === dev
yarn start:dev
else if ENV === prod
yarn start:prod
else
yarn start:dev
Any ideas?
This is the
if/elif/elseyou are looking for : (extrapolate this example to your own needs)Its possible to then use the .sh from the
package.jsonscripts(example) :... dont forget permissions :
chmod +x ./checkEnv.sh