I would like to take this article one step further. tldr: it talks about how to properly set an environment variable with Shelljs.
I have a large amount (~30) environment variables that are in a .sh file in a remote GH repo, that I’m not an owner of. To apply them on my computer I would simply run:
source env_vars.sh
I want to automate compiling the code of that repo, and thus apply any changes [from env_vars.sh] automatically. I’m using shelljs to run the other set of commands needed to compile the code, but it seems like I’m not able to source them with shelljs. Currently, I’m trying:
shell.exec('source env_vars.sh')
But I get:
/bin/sh: 1: source: not found
This makes sense as I understand that source
is a command specific to bash
. And as I understand, Shelljs uses sh
and not bash
to run its commands. So how could I get around this to apply a large amount of environment variables with Shelljs? I don’t want to add them in using shell.env["MM"]="2"
because then it wouldn’t be automated.
Thank you in advance for the help.