Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/egoist/yarn-install
Install dependencies using Yarn with npm fallback.
https://github.com/egoist/yarn-install
Last synced: 4 months ago
JSON representation
Install dependencies using Yarn with npm fallback.
- Host: GitHub
- URL: https://github.com/egoist/yarn-install
- Owner: egoist
- License: mit
- Created: 2016-10-28T10:52:35.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-01-12T09:52:21.000Z (about 2 years ago)
- Last Synced: 2024-10-10T12:03:28.495Z (4 months ago)
- Language: JavaScript
- Size: 464 KB
- Stars: 29
- Watchers: 3
- Forks: 4
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# yarn-install [](https://npmjs.com/package/yarn-install) [](https://npmjs.com/package/yarn-install) [](https://circleci.com/gh/egoist/yarn-install)
If command `yarn` exists it uses Yarn to install, otherwise fallbacks to npm.
> NOTE: to install packages in a directory, it's recommened to use [install-packages](https://github.com/egoist/install-packages) instead. In most cases that is a better choice.
## Install
```bash
$ npm install --save yarn-install
```## Usage
```js
const install = require('yarn-install')const result = install({
deps: ['webpack', 'mocha']
})
//=> result, returned by child_process.spawnSync
```## CLI
```bash
yarn global add yarn-install# then you will have `yarn-install` & `yarn-remove` commands
yarn-install pokemon --dev
yarn-install yo --global
yarn-remove xo
# don't forget that `yarn-install` with dependencies is always `--save` by default.yarn-install help
yarn-remove help
```## API
### install([options])
#### options
##### deps
Type: `array`
An array of dependencies to install, you can omit it to install dependencies in `package.json`. If `dependencies` is present, it defaults to `--save` mode.
```js
install({
deps: ['ava', 'koa']
})
```##### cwd
Type: `string`
The directory to run the command.
##### registry
Type: `string`
Specfic a custom npm registry to use.
##### dev
Type: `boolean`
Use `--dev` for Yarn and `--save-dev` for npm.
##### global
Type: `boolean`
Install globally, stands for `npm --global` or `yarn global`.
##### remove
Type: `boolean`
Default: `undefined`The reversed behavior to `install`, ie. `yarn remove` and `npm uninstall`
##### production
Type: `boolean`
Default: `undefined`Only install `dependencies` in `package.json`.
##### respectNpm5
Type: `boolean`
Default: `undefined`Use npm if it's >= npm5.
### install.getPm([options])
Get the package manager that will be used to install.
#### options
##### respectNpm5
```js
// Given you have yarn & npm 4 installed
const pm = install.getPm()
//=> yarn// Given you have yarn & npm 5 installed
const pm = install.getPm()
//=> yarn// Given you have yarn & npm 5 installed
const pm = install.getPm({ respectNpm5: true })
//=> npm
```## Contributing
1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -am 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request :D## License
[MIT](https://egoist.mit-license.org/) © [EGOIST](https://github.com/egoist)