├── .npmrc ├── .gitattributes ├── .gitignore ├── test.js ├── .editorconfig ├── .github └── workflows │ └── main.yml ├── readme.md ├── cli.js ├── package.json └── license /.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | yarn.lock 3 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | import {execa} from 'execa'; 3 | 4 | test('main', async t => { 5 | await t.throwsAsync(execa('./cli.js'), {message: /does not use Yarn/}); 6 | }); 7 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = tab 5 | end_of_line = lf 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [*.yml] 11 | indent_style = space 12 | indent_size = 2 13 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | - push 4 | - pull_request 5 | jobs: 6 | test: 7 | name: Node.js ${{ matrix.node-version }} 8 | runs-on: ubuntu-latest 9 | strategy: 10 | fail-fast: false 11 | matrix: 12 | node-version: 13 | - 24 14 | - 20 15 | steps: 16 | - uses: actions/checkout@v5 17 | - uses: actions/setup-node@v5 18 | with: 19 | node-version: ${{ matrix.node-version }} 20 | - run: npm install 21 | - run: npm test 22 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # has-yarn-cli 2 | 3 | > Check if a project is using [Yarn](https://yarnpkg.com) 4 | 5 | It checks for a `yarn.lock` file in the given directory or any of its parent directories (useful for Yarn workspaces). 6 | 7 | ## Install 8 | 9 | ```sh 10 | npm install --global has-yarn-cli 11 | ``` 12 | 13 | ## Usage 14 | 15 | ``` 16 | $ has-yarn --help 17 | 18 | Usage 19 | $ has-yarn 20 | ✔ This project uses Yarn 21 | 22 | Options 23 | --quiet Silence output (useful for scripts) 24 | 25 | Exits with code 0 if the project uses Yarn, otherwise code 2 26 | ``` 27 | 28 | ## Related 29 | 30 | - [has-yarn](https://github.com/sindresorhus/has-yarn) - API for this package 31 | -------------------------------------------------------------------------------- /cli.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import process from 'node:process'; 3 | import meow from 'meow'; 4 | import hasYarn from 'has-yarn'; 5 | import logSymbols from 'log-symbols'; 6 | 7 | const {flags} = meow(` 8 | Usage 9 | $ has-yarn 10 | ✔ This project uses Yarn 11 | 12 | Options 13 | --quiet Silence output (useful for scripts) 14 | 15 | Exits with code 0 if the project uses Yarn, otherwise code 2 16 | `, { 17 | importMeta: import.meta, 18 | flags: { 19 | quiet: { 20 | type: 'boolean', 21 | }, 22 | }, 23 | }); 24 | 25 | if (hasYarn()) { 26 | if (!flags.quiet) { 27 | console.log(`${logSymbols.success} This project uses Yarn`); 28 | } 29 | 30 | process.exit(0); 31 | } else { 32 | if (!flags.quiet) { 33 | console.log(`${logSymbols.error} This project does not use Yarn`); 34 | } 35 | 36 | process.exit(2); 37 | } 38 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "has-yarn-cli", 3 | "version": "3.0.0", 4 | "description": "Check if a project is using Yarn", 5 | "license": "MIT", 6 | "repository": "sindresorhus/has-yarn-cli", 7 | "funding": "https://github.com/sponsors/sindresorhus", 8 | "author": { 9 | "name": "Sindre Sorhus", 10 | "email": "sindresorhus@gmail.com", 11 | "url": "https://sindresorhus.com" 12 | }, 13 | "type": "module", 14 | "bin": { 15 | "has-yarn": "./cli.js" 16 | }, 17 | "engines": { 18 | "node": ">=20" 19 | }, 20 | "scripts": { 21 | "test": "xo && ava" 22 | }, 23 | "files": [ 24 | "cli.js" 25 | ], 26 | "keywords": [ 27 | "cli-app", 28 | "cli", 29 | "yarn", 30 | "has", 31 | "detect", 32 | "is", 33 | "project", 34 | "app", 35 | "module", 36 | "package", 37 | "manager", 38 | "npm" 39 | ], 40 | "dependencies": { 41 | "has-yarn": "^4.0.0", 42 | "log-symbols": "^7.0.1", 43 | "meow": "^13.2.0" 44 | }, 45 | "devDependencies": { 46 | "ava": "^6.4.1", 47 | "execa": "^9.6.0", 48 | "xo": "^1.2.2" 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Sindre Sorhus (https://sindresorhus.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | --------------------------------------------------------------------------------