UNPKG

1.55 kBMarkdownView Raw
1# install-g -- npm install -g {}
2
3One 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
91. Add `install-g` to your `package.json` dependencies.
102. Add `"scripts": { "install": "node_modules/.bin/install-g || true" }`
11
12As a result, any package using your package as a dependency would trigger its global installation.
13Use of devDependencies isn't recommended, unless your project is private.
14If you publish it on npm and others end up depending on it -- it will not install automatically...
15
16Because the install script is followed by `|| true`, non-zero exitcodes will be ignored.
17Thus a missing `./node_modules/.bin/install-g` won't be a problem. Nor will other possible errors
18such as the currently usupported `sudo` cause the install to fail. The error will still print
19to stderr, but a failed global install will not break the local install.
20I'm not sure if Windows can take the `|| true` though.
21
22Also note the use of `install` (i.e. `post-install`) rather than `pre-install`.
23If people run `install -g` on your package it will install once rather than twice.
24
25## Why
26
27Need not ask "please install {something} globally" - it just happens...
28See [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
33batshit test
34```
35
36## License
37
38[MIT](http://orlin.mit-license.org)