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
How it works
After the very 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:
npm-shrinkwrap.json- npm install
yarn.lock- yarn install
inpack.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.
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.
..."scripts":"start": "webpack""test": "ava"...
..."scripts":"start": "depy && webpack""test": "depy && ava"...
You can use
depy cache to recreate the cache without 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)