nps icon indicating copy to clipboard operation
nps copied to clipboard

Manipulating process.env from package-scrips.js

Open wmertens opened this issue 7 years ago • 2 comments

When putting something like process.env.hello = 'hi' in the package-scripts.js file, you get hello=hi in the spawned environment.

To me, that is a very nice feature, because I can provide helper vars to scripts, while the commands stay somewhat readable, e.g.

process.env.defDebug = '*,-babel,-something,-other'
if (!process.env.NODE_ENV) process.env.NODE_ENV = 'development'

module.exports = {scripts: {default: `\${DEBUG:-$defDebug} node script.js`}}

This will provide the default settings to DEBUG if it's not defined, and enforce NODE_ENV=development unless specified.

I'd like this feature to remain always; I can add it to the documentation if you like, but I have no idea how to write a test for it. I had a look at the tests but couldn't figure it out quickly.

wmertens avatar Jun 16 '18 14:06 wmertens

@wmertens So this issue is to say that this current feature simply needs documentation? I can write a test for it. If you're willing to document it, that would be great.

sezna avatar Aug 28 '19 15:08 sezna

Yes indeed :)

wmertens avatar Aug 28 '19 15:08 wmertens