Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to 10.0.0 breaks existing env-cmd npm scripts #88

Closed
PeterMerkert opened this issue Aug 30, 2019 · 5 comments
Closed

Update to 10.0.0 breaks existing env-cmd npm scripts #88

PeterMerkert opened this issue Aug 30, 2019 · 5 comments

Comments

@PeterMerkert
Copy link

Hi,

I am using env-cmd in versin 9.0.3 and greenkeeper just got me the update in. I tried it out and the command just fail with sh: line 1: 4041 Terminated: 15. I checked the changelogs but cannot find any breaking change affecting me, since I use vanilla NodeJS 12.8.1.

An example command as I have it in my package.json:
env-cmd cross-env DEBUG=false KNEX_SEED_DIR=./seeds/resetdb knex seed:run

I need to use the default .env file within my system and then override some env vars with cross-env. I would guess something about parsing this line has changed.

Maybe you can help me either "rewrite" the script so that I actually do not need both env-cmd and cross-env, or we find the bug breaking my script in the latest update.

Thanks!

@toddbluhm
Copy link
Owner

Yeah looks like something broke! Thanks for bringing this to my attention, I am looking into this right now.

@toddbluhm
Copy link
Owner

toddbluhm commented Aug 30, 2019

Fixed and just published 10.0.1. Thanks for bringing this to my attention so quickly. Please try out the fixed version and let me know if it works.

@toddbluhm
Copy link
Owner

As for your need to use cross-env for overriding, perhaps you could use the --fallback flag?

Create a .env.dev and then use this command env-cmd --fallback -f ./.env.dev. Then only have .env.dev exist in the environment you need the override vars in. This way, in your production environment it will not find .env.dev and "fallback" to the regular .env file you have containing your production vars. Perhaps that would work for your scenario?

@PeterMerkert
Copy link
Author

The new version works! Thanks 💯

Regarding my problem: I see what you mean, but I have several scripts and each of them would require a special env file then:

"db-seed": "env-cmd cross-env DEBUG=false KNEX_SEED_DIR=./seeds/base knex seed:run",
    "db-testseeds": "env-cmd cross-env DEBUG=false KNEX_SEED_DIR=./seeds/test knex seed:run",
    "db-reset": "env-cmd cross-env DEBUG=false KNEX_SEED_DIR=./seeds/resetdb knex seed:run",

And in production my env vars cme from the k8s cluster. So I do not even have env-cmd there any more.

Thanks a lot for this package, we really love it https://retraced.co/
And thanks for the quick update 👍

@toddbluhm
Copy link
Owner

Ah gotcha, that would be a pain then. The other solution is an .env-cmdrc file with multiple environments. If you cannot use a .rc file then you are out of luck at this time.

With a .rc file you could create one environment called shared with common environment vars, then three other environments for each of those other scripts. Then something like env-cmd -e shared,environment1 .... That way you get the benefit of shared env vars and overriding/merging of the environments together.

Glad to hear it is working. Sorry about the breakage! I had forgotten to run it through my env-cmd-examples repo before releasing 🤦‍♂

@toddbluhm toddbluhm pinned this issue Sep 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants