0

I'm currently using this to git tag a commit in Linux via bash:

"tag": "VER=v$(node -p \"require('./package.json').version\") && git tag -a \"$VER\" -m \"$VER\"",

Does anyone know a way to make this both Linux and Windows friendly?

basickarl
  • 37,187
  • 64
  • 214
  • 335
  • It doesn't answer the general question, but for this specific task note that `npm version` will create a tag by default when run in a git repo. – jonrsharpe Aug 07 '20 at 10:47
  • [Possible duplicate](https://stackoverflow.com/q/9153571/7665043). – l3l_aze Aug 08 '20 at 06:14
  • Does this answer your question? [How to set shell for npm run-scripts in Windows](https://stackoverflow.com/questions/23243353/how-to-set-shell-for-npm-run-scripts-in-windows) – Jo Liss Aug 19 '20 at 23:22

1 Answers1

0

Ok just found the easiest way: https://stackoverflow.com/a/46006249/1137669

Set npm to use bash on Windows.

npm config set script-shell "C:\\Program Files\\git\\bin\\bash.exe"
basickarl
  • 37,187
  • 64
  • 214
  • 335