nps icon indicating copy to clipboard operation
nps copied to clipboard

Set up all npm environment variables

Open kentcdodds opened this issue 8 years ago • 4 comments

If you run npm run env it'll show you all the environment variables that npm creates for you. It'd be handy to include those in the environment for the script that's run so there are fewer surprises when migrating from npm scripts to p-s, also, it can be handy in general :)

kentcdodds avatar Dec 20 '16 21:12 kentcdodds

@kentcdodds, I'm up for taking this one. Do you mind helping me out a little with the direction you would like it to go?

I see you have a getEnv function, would you like for me to handle this functionality there or pull in a function from another file that returns these env variables and merge the two in getEnv?

sloansparger avatar Feb 22 '17 00:02 sloansparger

Cool @sloansparger! Yes, I think this should happen in getEnv and I'm thinking that we can move it to its own module so it can be tested in isolation (so kind of a combination of what you suggested). I'm not certain how complicated it will be so it may be that you'll need to have a function or two in the new module and only expose the one getEnv as the default export. Thanks for taking this on! Please make sure to follow the contributing guidelines. :)

kentcdodds avatar Feb 22 '17 03:02 kentcdodds

@kentcdodds As I understand this just opens/proxies npm environment variables to the scripts run via nps, right? What about setting your own environment variables? I use better-npm-run (which, in fact, is based on your cross-env) to provide variables declaratively (useful for swapping database connection parameters and other API tokens for dev/test). But 'bnr' bloats the package.json even more, this could really help avoid that.

v1adko avatar Aug 09 '17 04:08 v1adko

What about setting your own environment variables?

I recommend just using cross-env. You can even use nps-utils which has a utility function for that :+1:

kentcdodds avatar Aug 10 '17 23:08 kentcdodds