Hi,
I’m trying to set an environment variable from the output of a command which finds the current nodejs project version, e.g.:
- run:
name: Get project version
command: |
if [ $CIRCLE_BRANCH = 'master' ]; then
echo export TAG=$(eval node -p "require('../package.json').version") >> $BASH_ENV
else
echo export TAG=$(eval node -p "require('../package.json').version")_$CIRCLE_BUILD_NUM >> $BASH_ENV
fi
However this doesn’t get executed correctly and I get the following error in the console logs:
/bin/bash: eval: line 3: syntax error near unexpected token `('
/bin/bash: eval: line 3: `node -p require('../package.json').version'
I’ve tried combinations of adding and escaping more quotes but nothing seems to work. Any ideas?
Thanks