{"id":18351680,"url":"https://github.com/charlesguse/run-script-os","last_synced_at":"2025-04-06T11:32:35.913Z","repository":{"id":37493471,"uuid":"91252805","full_name":"charlesguse/run-script-os","owner":"charlesguse","description":"run-script-os will let you use OS specific operations in npm scripts without specifying which OS you are on. It's not magic though... you still have to write OS specific scripts.","archived":false,"fork":false,"pushed_at":"2024-03-23T23:55:10.000Z","size":76,"stargazers_count":193,"open_issues_count":10,"forks_count":30,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-04T09:24:38.667Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/charlesguse.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-14T15:28:26.000Z","updated_at":"2024-09-21T07:26:57.000Z","dependencies_parsed_at":"2024-06-18T12:36:48.526Z","dependency_job_id":"fda4eb48-93d7-4105-a4d1-7eed098f02cd","html_url":"https://github.com/charlesguse/run-script-os","commit_stats":{"total_commits":111,"total_committers":12,"mean_commits":9.25,"dds":0.3513513513513513,"last_synced_commit":"9d20566670c4df85b6a139ac8dc7fb244c3721c3"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charlesguse%2Frun-script-os","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charlesguse%2Frun-script-os/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charlesguse%2Frun-script-os/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charlesguse%2Frun-script-os/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/charlesguse","download_url":"https://codeload.github.com/charlesguse/run-script-os/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247478151,"owners_count":20945257,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T21:32:11.490Z","updated_at":"2025-04-06T11:32:35.558Z","avatar_url":"https://github.com/charlesguse.png","language":"JavaScript","readme":"# run-script-os\n\nYou will be able to use OS specific operations in npm scripts.\n\n## Who would want this?\nIf you have experienced the pain of trying to make npm scripts usable across different operating system, this package is for you! Looking at you `rm` and `del`!\n\n## Installation\n`npm install --save-dev run-script-os`\n\n## Usage\n\nSet `run-script-os` (or `run-os`) as the value of the npm script field that you want different functionality per OS. In the example below, we set `test`, but it can be any npm script. It also uses `pre` and `post` commands (explained more below).\n\nThen create OS specific scripts. In the example below, you can see:\n\n* `test:win32`\n* `test:linux:darwin`\n* `test:default`\n\nThose can have OS specific logic.\n\n`package.json`\n```\n{\n  ...\n  \"scripts\": {\n    ...\n    \"test\": \"run-script-os\",\n    \"test:win32\": \"echo 'del whatever you want in Windows 32/64'\",\n    \"test:darwin:linux\": \"echo 'You can combine OS tags and rm all the things!'\",\n    \"test:default\": \"echo 'This will run on any platform that does not have its own script'\"\n    ...\n  },\n  ...\n}\n```\n\n**Windows Output:**\n```\n\u003e npm test\ndel whatever you want in Windows 32/64\n```\n\n**macOS and Linux Output:**\n```\n\u003e npm test\nYou can combine OS tags and rm all the things!\n```\n\n### Aliases\n\nYou can use the following aliases:\n\n* `:windows` - Alias for win32\n* `:macos` - Alias for darwin\n* `:nix` - This will run on anything considered to be a *nix OS (aix, darwin, freebsd, linux, openbsd, sunos, android)\n* `:default` - This will run if no platform-specific scripts are found\n\n### Override detection settings for linux-based shells on Windows\n\nBy default, run-script-os will detect cygwin/git bash as Windows. If you would rather your platform be detected as Linux under these environments:\n\nSet environment variable:\n\n```\nRUN_OS_WINBASH_IS_LINUX=true\n```\n\n### NPM Scripts Order\nWhen you call a script like `npm test`, npm will first call `pretest` if it exists. It will then call `test`, which, if you are using `run-script-os`, it will then call `npm run test:YOUR OS`, which in turn will call `pretest:YOUR OS` before actually running `test:YOUR OS`. Then `posttest:YOUR OS` will run, and then after that `posttest` will finally execute.\n\nThere is an example showing `pre` and `post` commands found in the [`package.json` of this repository](https://github.com/charlesguse/run-script-os/blob/master/package.json).\n\nOS Options: `darwin`, `freebsd`, `linux`, `sunos`, `win32`\n\nMore information can be found in [Node's `process.platform`](https://nodejs.org/api/process.html#process_process_platform) and [Node's `os.platform()`](https://nodejs.org/api/os.html#os_os_platform).\n","funding_links":[],"categories":["Packages"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharlesguse%2Frun-script-os","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcharlesguse%2Frun-script-os","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharlesguse%2Frun-script-os/lists"}