1 | # install-g -- npm install -g {}
|
2 |
|
3 | One can insist to automatically npm-install a package globally.
|
4 |
|
5 | [![NPM](https://nodei.co/npm/install-g.png?mini=true)](https://www.npmjs.org/package/install-g)
|
6 |
|
7 | ## Use
|
8 |
|
9 | 1. Add `install-g` to your `package.json` dependencies.
|
10 | 2. Add `"scripts": { "install": "node_modules/.bin/install-g || true" }`
|
11 |
|
12 | As a result, any package using your package as a dependency would trigger its global installation.
|
13 | Use of devDependencies isn't recommended, unless your project is private.
|
14 | If you publish it on npm and others end up depending on it -- it will not install automatically...
|
15 |
|
16 | Because the install script is followed by `|| true`, non-zero exitcodes will be ignored.
|
17 | Thus a missing `./node_modules/.bin/install-g` won't be a problem. Nor will other possible errors
|
18 | such as the currently usupported `sudo` cause the install to fail. The error will still print
|
19 | to stderr, but a failed global install will not break the local install.
|
20 | I'm not sure if Windows can take the `|| true` though.
|
21 |
|
22 | Also note the use of `install` (i.e. `post-install`) rather than `pre-install`.
|
23 | If people run `install -g` on your package it will install once rather than twice.
|
24 |
|
25 | ## Why
|
26 |
|
27 | Need not ask "please install {something} globally" - it just happens...
|
28 | See [install-g's dependents](https://www.npmjs.org/package/install-g) for example.
|
29 |
|
30 | ## Testing [![Build Status](https://img.shields.io/travis/orlin/install-g.svg?style=flat)](http://travis-ci.org/orlin/install-g)
|
31 |
|
32 | ```sh
|
33 | batshit test
|
34 | ```
|
35 |
|
36 | ## License
|
37 |
|
38 | [MIT](http://orlin.mit-license.org)
|