I have a task in my package.json "deploy", which needs to first call "build". I have specified it like this:
"deploy": "yarn run build; ./deploy.sh",
The problem is that this hard codes yarn
as the package manager. So if someone doesn't use yarn
, it doesn't work. Switching to npm
causes a similar issue.
What's a good way to achieve this while remaining agnostic to the choice of npm
or yarn
?
So I think I have a much simpler solution:
"deploy": "yarn run build || npm run build; ./deploy.sh",
Its only real downside is in the case where yarn exists, but the build fails, then npm run build
will also take place.