kentcdodds / cross-env

🔀 Cross platform setting of environment scripts

Home Page:https://www.npmjs.com/package/cross-env

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cross-env with git tag

BhaveshSGupta opened this issue · comments

  • cross-env version: ^5.2.0
  • node version: 10.15.0
  • npm (or yarn) version: 6.4.1

Relevant code or config

"make": "cross-env APP_ENV=production cross-env APP_VERSION=`git tag --points-at HEAD` cross-env APP_COMMIT=`git rev-parse HEAD` webpack --config webpack.config.js"

What you did:
When using above code in package.json and running it as npm run-script make

What happened:

Gives below error.
image

Reproduction repository:

Problem description:

Suggested solution:

The common patterns seems to be crossenv [declaration] [command] where your command would be another crossenv.
Have you tried an explicit end at the end of each command?

cross-env APP_ENV=production; cross-env APP_VERSION=`git tag --points-at HEAD`; cross-env APP_COMMIT=`git rev-parse HEAD` webpack --config webpack.config.js

Not sure if that will carry on the variables though.
I thought this may be the solution:

"make": "cross-env-shell \"APP_ENV=production cross-env APP_VERSION=`git tag --points-at HEAD` cross-env APP_COMMIT=`git rev-parse HEAD` webpack --config webpack.config.js\"",

What is the minimal command to reproduce this?

Does this work?

"make": "cross-env APP_VERSION=`git tag --points-at HEAD` echo $APP_VERSION`

@jaller94, I was able to fix this by you using something like
"make": "cross-env APP_ENV=production cross-env APP_VERSION=\"git tag --points-at HEAD\" cross-env APP_COMMIT=\"git rev-parse HEAD\" webpack --config webpack.config.js"