Skip to content

Manipulating process.env from package-scrips.js #179

@wmertens

Description

@wmertens

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions