joh / when-changed

Execute a command when a file is changed
Other
1.21k stars 107 forks source link

fix issue #73: support for environment variables #74

Closed eviweb closed 5 years ago

eviweb commented 5 years ago

It provides a new dict attribute process_env and a setter method called set_envvar. The latter accepts two arguments: name and value The name does not need to be passed in uppercase, and will automatically be prefixed with WHEN_CHANGED_ to prevent conflicts. eg. self.set_envvar('myvar', 'myvalue') will result in an environment variable WHEN_CHANGED_MYVAR = myvalue.

Only the sub process is altered as suggested here https://github.com/joh/when-changed/pull/72#pullrequestreview-217539245 and shown here https://stackoverflow.com/questions/2231227/python-subprocess-popen-with-a-modified-environment

Signed-off-by: Eric Villard dev@eviweb.fr

joh commented 5 years ago

Great, thanks!