yarn-install
Install dependencies using Yarn with npm fallback.
Last updated 8 years ago by rem .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install yarn-install 
SYNC missed versions from official npm registry.

yarn-install NPM version NPM downloads Build Status

If command yarn exists it uses Yarn to install, otherwise fallbacks to npm.

Install

$ npm install --save yarn-install

Usage

const install = require('yarn-install')

const result = install({
  deps: ['webpack', 'mocha']
})
//=> result, returned by child_process.spawnSync

CLI

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.

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
// 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 © EGOIST

Current Tags

  • 1.0.0                                ...           latest (8 years ago)

11 Versions

  • 1.0.0                                ...           8 years ago
  • 0.5.1                                ...           9 years ago
  • 0.5.0                                ...           9 years ago
  • 0.4.2                                ...           9 years ago
  • 0.4.1                                ...           9 years ago
  • 0.4.0                                ...           9 years ago
  • 0.3.0                                ...           9 years ago
  • 0.2.1                                ...           9 years ago
  • 0.2.0                                ...           9 years ago
  • 0.1.1                                ...           9 years ago
  • 0.1.0                                ...           9 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 0
Dependencies (3)
Dev Dependencies (6)
Dependents (3)

Copyright 2013 - present © cnpmjs.org | Home |