There’s an NPM package called run-script-os
( NPM | GitHub ) that doesn’t require you to write any additional files, and this can be convenient if what you’re trying to do is very simple. For example, in your package.json
, you might have something like:
"scripts": {
"test": "run-script-os",
"test:darwin:linux": "export NODE_ENV=test && mocha",
"test:win32": "SET NODE_ENV=test&& mocha"
}
Then you could run npm test
on Windows, Mac, or Linux and get similar (or different!) results on each.