I am using Grunt, and specifically, the grunt-concurrent plugin, which takes a list of tasks to run concurrently, and spawns concurrent child processes for each of those tasks. (Note: it is a requirement for me on this project to use grunt-concurrent and to spawn these child processes).
In the parent process (the initial run of Grunt that the user fired off on the command line), I have access to all the information sent on the command line (such as, cmd args, which tasks were requested, etc.) However, the spawned Grunt processes do not pass all that info. (In particular, I no longer have the tasks that were requested.)
I figured one way I can keep this context, is by setting environment variables in the parent process, via process.env[MY_VAR] = value
. However, though those variables register in the parent process, they are no longer defined in the child processes spawned by grunt-concurrent.
What is the best way to set environment variables in the parent Grunt process, so that the child Grunt processes have access to them? Or is there already a way to get access to ALL the information the parent process had? (Meaning, even the list of tasks?), in the child processes spawned by grunt-concurrent? Alternatively - is there a way to keep the parent Grunt process alive until all the children have completed? (I think the reason I'm losing the process.env settings, is because grunt-concurrent spawns the children, and then that parent process completes.)