├── .editorconfig ├── .gitignore ├── README.md ├── index.js └── package.json /.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | # editorconfig.org 3 | root = true 4 | 5 | [*] 6 | indent_style = space 7 | indent_size = 2 8 | end_of_line = lf 9 | charset = utf-8 10 | trim_trailing_whitespace = true 11 | insert_final_newline = true 12 | 13 | [*.md] 14 | trim_trailing_whitespace = true 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | 11 | # Directory for instrumented libs generated by jscoverage/JSCover 12 | lib-cov 13 | 14 | # Coverage directory used by tools like istanbul 15 | coverage 16 | 17 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 18 | .grunt 19 | 20 | # node-waf configuration 21 | .lock-wscript 22 | 23 | # Compiled binary addons (http://nodejs.org/api/addons.html) 24 | build/Release 25 | 26 | # Dependency directory 27 | node_modules 28 | 29 | # Optional npm cache directory 30 | .npm 31 | 32 | # Optional REPL history 33 | .node_repl_history 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # use-yarn-instead 2 | 3 | ![unstable](https://img.shields.io/badge/status-unstable-yellow.svg) 4 | 5 | This package is a playground for technically enforcing the use of `yarn` instead of `npm` on a project. You can read [@farisj's use case](https://github.com/alexanderwallin/use-yarn-instead/issues/1#issuecomment-277493922) to get a kind of rationale for it. 6 | 7 | You should probably not be using this! 8 | 9 | ## Usage 10 | 11 | The published package hooks up to the `postinstall` npm hook and displays a message when a developer runs `npm install` instead of `yarn install`. The problem with this is that it does not stop the installation process. Also, the warning will be superseeded by a massive package depenceny graph, which will almost guaranteedly make people miss it. 12 | 13 | Example: 14 | 15 | ```sh 16 | $ npm install 17 | 18 | # npm output... 19 | 20 | ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 21 | 22 | Psst, use `yarn` instead 23 | 24 | ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 25 | 26 | # npm graph... 27 | 28 | $ 29 | ``` 30 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | const psList = require('ps-list') 3 | const colors = require('colors') 4 | 5 | psList() 6 | .then(results => { 7 | const yarnProcess = results.filter(p => p.name === 'yarn').shift() 8 | if (!yarnProcess) { 9 | console.log(` 10 | ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 11 | 12 | Psst, use \`yarn\` instead 13 | 14 | ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 15 | 16 | `.red) 17 | } 18 | }) 19 | .catch(err => console.log('error:', err)) 20 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "use-yarn-instead", 3 | "version": "0.2.2", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "postinstall": "./index.js" 8 | }, 9 | "keywords": [], 10 | "author": "Alexander Wallin (http://alexanderwallin.com)", 11 | "license": "ISC", 12 | "dependencies": { 13 | "colors": "^1.1.2", 14 | "ps-list": "^3.1.0" 15 | } 16 | } 17 | --------------------------------------------------------------------------------