{"id":17050555,"url":"https://github.com/bendingbender/yarpm","last_synced_at":"2025-04-12T15:20:57.114Z","repository":{"id":55098856,"uuid":"82302232","full_name":"BendingBender/yarpm","owner":"BendingBender","description":"CLI tool to run npm scripts with either npm, pnpm, or yarn, depending on how it was started","archived":false,"fork":false,"pushed_at":"2022-12-27T10:57:04.000Z","size":103,"stargazers_count":46,"open_issues_count":2,"forks_count":9,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-09T20:16:09.626Z","etag":null,"topics":["cli","cross-platform","nodejs","npm","npm-package","npm-scripts","pnpm","yarn"],"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/BendingBender.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2017-02-17T13:56:59.000Z","updated_at":"2024-11-30T05:19:33.000Z","dependencies_parsed_at":"2023-01-31T03:15:13.732Z","dependency_job_id":null,"html_url":"https://github.com/BendingBender/yarpm","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BendingBender%2Fyarpm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BendingBender%2Fyarpm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BendingBender%2Fyarpm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BendingBender%2Fyarpm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BendingBender","download_url":"https://codeload.github.com/BendingBender/yarpm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248586217,"owners_count":21128998,"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","cross-platform","nodejs","npm","npm-package","npm-scripts","pnpm","yarn"],"created_at":"2024-10-14T09:57:10.195Z","updated_at":"2025-04-12T15:20:57.089Z","avatar_url":"https://github.com/BendingBender.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# yarpm\n\n[![NPM version][npm-version]][npm-url]\n[![NPM downloads][npm-downloads]][npm-url]\n[![NPM total downloads][npm-total-downloads]][npm-url]\n[![Test results][github-actions-tests]][github-actions-tests-url]\n\n## Summary\n\nA CLI tool to run npm scripts with either `npm`, `pnpm` or `yarn`, depending on how it was started. Useful for setups\nwhere some team members use `npm` while others use `pnpm` or `yarn`, especially when Windows and Unix-like systems are\nused across the team.\n\nThis tool is a helper to run scripts from `package.json`. Just substitute all `npm`, `pnpm` or `yarn` calls with `yarpm`\nand you're good to go:\n\n```json\n{\n  \"scripts\": {\n    \"start\": \"yarpm run build\",\n    \"build\": \"tsc index.ts\"\n  }\n}\n```\n\nWhen running the `start` script with `yarn start`, the dependent `build` script will be spawned with `yarn`:\n\n```bash\n~/test$ yarn start\nyarn start v1.22.5\n$ yarpm run build\n$ tsc index.ts\n✨  Done in 2.27s.\n```\n\nRunning the same script with `npm start` will result in the dependent `build` being run with `npm`:\n\n```bash\n~/test$ npm start\n\n\u003e test@0.0.1 start /home/me/test\n\u003e yarpm run build\n\n\n\u003e test@0.0.1 build /home/me/test\n\u003e tsc index.ts\n```\n\n## What this tool is _not_\n\nThis tool is not meant to be an abstraction layer for calling `npm`, `pnpm` or `yarn`. It will pass **all** arguments\nit receives unfiltered to the chosen package manager. You'll have to make sure that the package manager commands you use\nare compatible with all the package managers you want your commands to work with.\n\n## Installation\n\n```bash\n$ npm install yarpm --save-dev\n# or\n$ pnpm add yarpm --save-dev\n# or\n$ yarn add yarpm --dev\n```\n\n## CLI Commands\n\nThe `yarpm` package provides 3 CLI commands:\n\n- [yarpm](#yarpm-1)\n- [yarpm-pnpm](#yarpm-pnpm)\n- [yarpm-yarn](#yarpm-yarn)\n\nThe main command is `yarpm`.\n\n### yarpm\n\nThis command is an in-place substitute for places in `package.json` where `npm`, `pnpm` or `yarn` is being used\nexplicitly. It reads the `npm_execpath` environment variable to determine the path to the currently used package\nmanager. This env var is only set when running `yarpm` as a script. If `yarpm` is used without being embedded\nin a script, it will **always** choose `npm`.\n\n### yarpm-pnpm\n\nThis command can be used in places where you are not in control of how your script is being started, for example when\nusing `husky` to run a script as a git hook. This script will **always** prefer `pnpm` over `npm` unless `pnpm` is not\navailable. Only then will it fall back to `npm`.\n\n### yarpm-yarn\n\nThis command can be used in places where you are not in control of how your script is being started, for example when\nusing `husky` to run a script as a git hook. This script will **always** prefer `yarn` over `npm` unless `yarn` is not\navailable. Only then will it fall back to `npm`.\n\n## Node API\n\nThe `yarpm` package provides a node API.\n\n```js\nconst yarpm = require('yarpm');\nconst promise = yarpm(argv, options);\n```\n\n- **argv** `string[]` -- The argument list to pass to npm/pnpm/yarn.\n- **options** `object|undefined`\n  - **options.npmPath** `string` -\n    The path to npm/pnpm/yarn.\n    Default is `process.env.npm_execpath` if set, `npm` otherwise.\n  - **options.env** `object` -\n    Sets the environment key-value pairs, replaces the default usage of process.env to spawn child process.\n  - **options.stdin** `stream.Readable|null` --\n    A readable stream to send messages to stdin of child process.\n    If this is `null` or `undefined`, ignores it.\n    If this is `process.stdin`, inherits it.\n    Otherwise, makes a pipe.\n    Default is `null`.\n    Set to `process.stdin` in order to send from stdin.\n  - **options.stdout** `stream.Writable|null` --\n    A writable stream to receive messages from stdout of child process.\n    If this is `null` or `undefined`, cannot send.\n    If this is `process.stdout`, inherits it.\n    Otherwise, makes a pipe.\n    Default is `null`.\n    Set to `process.stdout` in order to print to stdout.\n  - **options.stderr** `stream.Writable|null` --\n    A writable stream to receive messages from stderr of child process.\n    If this is `null` or `undefined`, cannot send.\n    If this is `process.stderr`, inherits it.\n    Otherwise, makes a pipe.\n    Default is `null`.\n    Set to `process.stderr` in order to print to stderr.\n\n`yarpm` returns a promise will be _resolved_ when the spawned process exits, **_regardless of the exit code_**.\nThe promise will be _rejected_ in case of an internal error inside of `yarpm`.\n\nThe promise is resolved with an object with the following 2 properties: `spawnArgs` and `code`.\nThe `spawnArgs` property contains the array of parameters that were passed to spawn the sub-process.\nThe `code` property is the exit code of the sub-process.\n\n```js\nyarpm(['install']).then((result) =\u003e {\n  console.log(`${result.spawnArgs} -- ${result.code}`);\n  // if executed as a package.json script via yarn: /usr/share/yarn/bin/yarn.js,install -- 0\n});\n```\n\n## Changelog\n\nhttps://github.com/BendingBender/yarpm/blob/master/CHANGELOG.md\n\n## Contributing\n\nClone the repo and make a pull request. Thank you for contributing!\n\n### Bug Reports or Feature Requests\n\nPlease use GitHub Issues.\n\n## License\n\n[MIT](https://github.com/BendingBender/yarpm/blob/master/LICENSE)\n\n[npm-url]: https://www.npmjs.com/package/yarpm\n[npm-version]: https://shields.io/npm/v/yarpm.svg\n[npm-downloads]: https://shields.io/npm/dm/yarpm.svg\n[npm-total-downloads]: https://shields.io/npm/dt/yarpm?label=total+downloads\n[github-actions-tests]: https://img.shields.io/github/actions/workflow/status/BendingBender/yarpm/tests.yml?branch=master\n[github-actions-tests-url]: https://github.com/BendingBender/yarpm/actions?query=workflow%3A%22Run+Tests%22\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbendingbender%2Fyarpm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbendingbender%2Fyarpm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbendingbender%2Fyarpm/lists"}