https://github.com/milewski/cross-os
Allow adding OS-specific scripts in your package.json!
https://github.com/milewski/cross-os
cross-env cross-platform cross-script npm-scripts os-specific
Last synced: about 2 months ago
JSON representation
Allow adding OS-specific scripts in your package.json!
- Host: GitHub
- URL: https://github.com/milewski/cross-os
- Owner: milewski
- License: mit
- Created: 2017-04-13T06:51:28.000Z (about 8 years ago)
- Default Branch: main
- Last Pushed: 2024-10-25T05:21:37.000Z (7 months ago)
- Last Synced: 2025-03-29T03:09:42.902Z (about 2 months ago)
- Topics: cross-env, cross-platform, cross-script, npm-scripts, os-specific
- Language: TypeScript
- Homepage:
- Size: 87.9 KB
- Stars: 44
- Watchers: 2
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# cross-os
[](https://badge.fury.io/js/cross-os)
[](https://www.npmjs.com/package/cross-os)OS Specific npm scripts! Ideal for tasks that differs across Operating System Platforms
## Install
```bash
$ npm install cross-os --save-dev
```## Usage
Add scripts to your package.json like so:
- it supports `darwin`, `freebsd`, `linux`, `sunos` or `win32````json
"scripts": {
"foo": "cross-os bar",
"bar": {
"darwin": "echo 'i will only run on Mac'",
"win32": "echo 'i will only run on Windows'",
"linux": "echo 'i will only run on Linux'"
}
}
```
And call it like:
```
npm run foo
```Alternatively you can also specify scripts on its own section in your `package.json`
```json
"scripts": {
"foo": "cross-os bar"
}
"cross-os": {
"bar": {
"darwin": "echo 'i will only run on Mac'",
"win32": "echo 'i will only run on Windows'",
"linux": "echo 'i will only run on Linux'"
}
}
```You also can pass args to the underlying script like this:
```json
"scripts": {
"foo": "cross-os bar -- arg1 arg2"
}
"cross-os": {
"bar": {
"darwin": "echo received arg: ",
"win32": "echo received arg: ",
"linux": "echo received arg: "
}
}
```or directly from the npm run script like this:
```bash
npm run foo -- arg1 arg2
```## License
[MIT](LICENSE) © [Rafael Milewski](https://github.com/milewski)