Hi does anyone know if …

less than 1 minute read

Hi, does anyone know if there is way to add environment variables to targets in workspace.json?

Responses:

I’m porting a library that has to export NODE_ICU_DATA before running tests.

Is there a way to add this export NODE_ICU_DATA='./node_modules/full-icu' to the test command for this lib so that however the test for that lib run, they export that data?

easiest way is probably to add it to a package.json script

see https://corgibytes.com/blog/2017/04/18/npm-tips/

and the section called RUNNING MULTIPLE COMMANDS IN SERIES OR IN PARALLEL

Thanks, I have used the approach in the old project.

The problem is that I don’t really want to add the export in front of the main nx affected:test script. I only need the env var when running tests for one lib.

It’s not the end of the world but I’d rather keep the scripts in the main package.json clean and only applies the env vars to the test target that need it

fair play. I don’t have any immediate solution that comes to mind

You’re kind of after some Nx cli lifecycle hooks

Updated: