Depy is a small cli tool that watches your project dependencies and runs the appropriate package manager when it is needed. Depy tracks changes in package.json, npm-shrinkwrap.json, yarn.lock, inpack.json.
npm install --save-dev depy
After the first run, depy creates project confuguration files cache. From now on, when the tool is running, it will be comparing all the configuration files with the cache. If there are any inconsistencies, depy will run the appropriate tool to update dependecies.
Depy runs different commands for each type of config:
package.json
andnpm-shrinkwrap.json
- npm installyarn.lock
- yarn installinpack.json
- inpack link
Also depy can detect yarn ("yarn install" will be executed instead of "npm install"). If npm-shrinkwrap.json exists and was changed, "npm install" will be executed in any case.
$ depy
Since depy is the tool for developers, you need to install it with --save-dev
npm flag (or -D
for yarn). You can run depy manually, but it might be annoying doing this every time. So, you can simply add depy to your npm-scripts.
package.json before
...
"scripts": {
"start": "webpack",
"test": "ava"
},
...
package.json after
...
"scripts": {
"start": "depy && webpack",
"test": "depy && ava"
},
...
You can use depy cache
to recreate the cache without running any package manager. Makes sense to add this script to the "postinstall" section. It is a good way to avoid an unnecessary package manager launch after installing new dependencies.
In this case, your modified package.json will be:
...
"scripts": {
"start": "depy && webpack",
"test": "depy && ava"
},
"postinstsall": "depy cache",
...
--dir
- project directory (current directory by default)--cache-dir
- cache directory (depy installation directory by default)