{"id":15769648,"url":"https://github.com/mysticatea/if-node-version","last_synced_at":"2025-05-07T14:12:41.176Z","repository":{"id":57271430,"uuid":"62450520","full_name":"mysticatea/if-node-version","owner":"mysticatea","description":"Run a shell command if it's on the node of specified versions.","archived":false,"fork":false,"pushed_at":"2020-07-21T12:34:58.000Z","size":25,"stargazers_count":14,"open_issues_count":2,"forks_count":15,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-20T08:42:13.851Z","etag":null,"topics":["cli","cli-command","node","nodejs","npm","npm-module","npm-package","npm-scripts","version","version-check"],"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/mysticatea.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}},"created_at":"2016-07-02T12:49:06.000Z","updated_at":"2023-09-08T17:12:12.000Z","dependencies_parsed_at":"2022-09-01T00:42:40.819Z","dependency_job_id":null,"html_url":"https://github.com/mysticatea/if-node-version","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mysticatea%2Fif-node-version","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mysticatea%2Fif-node-version/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mysticatea%2Fif-node-version/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mysticatea%2Fif-node-version/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mysticatea","download_url":"https://codeload.github.com/mysticatea/if-node-version/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252436272,"owners_count":21747469,"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":["cli","cli-command","node","nodejs","npm","npm-module","npm-package","npm-scripts","version","version-check"],"created_at":"2024-10-04T14:03:43.927Z","updated_at":"2025-05-07T14:12:41.159Z","avatar_url":"https://github.com/mysticatea.png","language":"JavaScript","readme":"# if-node-version\n\n[![npm version](https://img.shields.io/npm/v/if-node-version.svg)](https://www.npmjs.com/package/if-node-version)\n[![Downloads/month](https://img.shields.io/npm/dm/if-node-version.svg)](http://www.npmtrends.com/if-node-version)\n[![Build Status](https://travis-ci.org/mysticatea/if-node-version.svg?branch=master)](https://travis-ci.org/mysticatea/if-node-version)\n[![Coverage Status](https://codecov.io/gh/mysticatea/if-node-version/branch/master/graph/badge.svg)](https://codecov.io/gh/mysticatea/if-node-version)\n[![Dependency Status](https://david-dm.org/mysticatea/if-node-version.svg)](https://david-dm.org/mysticatea/if-node-version)\n\nRun a shell command if it's on the node of specified versions.\n\n```bash\n$ if-node-version \"\u003e=4\" eslint lib test\n```\n\n```bash\n$ if-node-version \"\u003c6\" node ./scripts/fallback.js\n```\n\nMaybe this helps you together with [npm-scripts].\n\n## Installation\n\n`if-node-version` can be installed with [npm].\n\n```bash\n$ npm install --save-dev if-node-version\n```\n\n- `if-node-version` requires Node.js `\u003e=0.10.0`\n\n## Usage\n\n### CLI\n\n```\nUsage:\n    $ if-node-version \u003cVersionRange\u003e \u003cCommand\u003e [...args]\n\n        Run a shell command if it's on the node of specified versions.\n        Otherwise, do nothing.\n\n        Exit code is the exit code of the \u003cCommand\u003e.\n\n    $ if-node-version \u003cVersionRange\u003e\n\n        Check if it's on the node of specified versions.\n\n        Exit code is 0 if it's on the node of specified versions.\n        Otherwise, exit code is 1.\n\n    $ if-node-version --help\n\n        Show this help text.\n\n    $ if-node-version --version\n\n        Show the version number of `if-node-version` command.\n\nParameters:\n    \u003cVersionRange\u003e .... A text which specifies the version range of Node.js\n                        This text format is defined by node-semver module:\n                        https://www.npmjs.com/package/semver#ranges\n    \u003cCommand\u003e ......... The shell command to execute.\n    [...args] ......... Parameters of the shell command.\n\nExamples:\n    $ if-node-version \"\u003e=4\" eslint lib test\n    $ if-node-version \"\u003c6\" node ./scripts/fallback.js\n```\n\n### Node API\n\n```js\nvar spawnIfNodeVersion = require(\"if-node-version\")\n```\n\n#### spawnIfNodeVersion(versionRange, command, args, options)\n\nSpawn a child process with specified parameters if the node version satisfies a given version range.\n\nThis function returns [child_process.ChildProcess] object.\n\n- `versionRange` `{string}` - A text which specifies the version range of Node.js. This text format is defined by node-semver module: https://www.npmjs.com/package/semver#ranges\n- `command` `{string}` - The command to run.\n- `args` `{Array.\u003cstring\u003e}` - List of string arguments.\n- `options` `{object}` - An option object. See [the document of `child_process.spawn`]\n\n#### spawnIfNodeVersion.sync(versionRange, command, args, options)\n\nThis is synchronous version of `spawnIfNodeVersion(versionRange, command, args, options)`.\n\nThis function returns the object as same as [child_process.spawnSync].\n\n**Note:** If you use this function on node `0.10`, you will also need to install [spawn-sync].\n\n## Changelogs\n\n- [GitHub Releases]\n\n## Contributing\n\nWelcome your contributions!\u003cbr\u003e\nPlease use GitHub's issues/PRs.\n\n### Tools to develop\n\n- `npm install` installs dependencies.\n- `npm test` runs tests and measures coverage.\n- `npm run coverage` opens the coverage result of `npm test`.\n- `npm run clean` removes the coverage result of `npm test`.\n- `npm run lint` analyzes codes by ESLint.\n- `npm run watch` runs tests (without coverage measurement) when source code is modified.\n\n\n[npm]: https://www.npmjs.com/\n[npm-scripts]: https://docs.npmjs.com/misc/scripts\n[child_process.ChildProcess]: https://nodejs.org/api/child_process.html#child_process_class_childprocess\n[the document of `child_process.spawn`]: https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options\n[child_process.spawnSync]: https://nodejs.org/api/child_process.html#child_process_child_process_spawnsync_command_args_options\n[spawn-sync]: https://www.npmjs.com/package/spawn-sync\n[GitHub Releases]: https://github.com/mysticatea/if-node-version/releases\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmysticatea%2Fif-node-version","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmysticatea%2Fif-node-version","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmysticatea%2Fif-node-version/lists"}