Npm scripts: is there a conditional statement for cross platform?

I am trying to move an npm package *nixfrom cross platform dependent. I have a record of the following scripts in package.json:

"scripts": {
    "build": "rimraf dist/ && tsc",
    // other entries
    "prepublish": "if [ ! $SKIP_PREPUBLISH ]; then npm run build; fi"
  },

I want to take if [ ! $SKIP_PREPUBLISH ]; then npm run build; fiand make this cross platform. Is there any way to do this?

+4
source share
1 answer

Starting with npm 5.1.0you can change the shell script.

I put this line in a file .npmrcand it works:

script-shell = C:\Program Files\Git\bin\bash.exe

You can also run this command:

npm config set --userconfig script-shell "C:\\Program Files\\Git\\bin\\bash.exe"

0
source

All Articles