Execute child process - How to distinguish between Linux and Windows?


#1

I have to run a child process within my package. Such process would require an environment variable in order to properly perform, but this of course raises a difference between Linux and Windows systems.

I’m writing my command this way:

{exec} = require 'child_process'
...
apm = atom.config.getApmPath()
child = exec 'myVar=someValue ' + apm + ' install something'

This is clearly failing in Windows environments, since my command should be something like:

child = exec 'set myVar=someValue ' + apm + ' install something'

Is there a way to get the working environment under Atom? Am I supposed to use some sort of workaround, like checking for the root folder or the nodepad.exe?


#2

Have you tried process.env to see if the environment is inherited by the child processes?


#3

I think that’s exactly what I’m looking for! Cheers!