function resolveEnvVars(varValue) {
  const envUnixRegex = /(\\*)(\$(\w+)|\${(\w+)})/g // $my_var or ${my_var} or \$my_var
  return varValue.replace(
    envUnixRegex,
    (_, escapeChars, varNameWithDollarSign, varName, altVarName) => {
      // do not replace things preceded by a odd number of \
      if (escapeChars.length % 2 === 1) {
        return varNameWithDollarSign
      }
      return (
        escapeChars.substr(0, escapeChars.length / 2) +
        (process.env[varName || altVarName] || '')
      )
    },
  )
}
This will attempt to resolve the value of any env variables that are inside
this string. For example, it will transform this:
cross-env FOO=$NODE_ENV BAR=\\$NODE_ENV echo $FOO $BAR
Into this:
FOO=development BAR=$NODE_ENV echo $FOO
(Or whatever value the variable NODE_ENV has)
Note that this function is only called with the right-side portion of the
env var assignment, so in that example, this function would transform
the string "$NODE_ENV" into "development"
@param {String} varValue Original value of the env variable
@returns {String} Converted value