UNPKG

sync-modules

Version:

automatically keep node_modules in sync with Git hooks

43 lines (26 loc) 2.02 kB
# sync-modules [![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard) This package may be interesting to you if you're developing using Node.js and Git. ## The Problem At the beginning of your workday you `git pull` the latest changes from your coworkers and start working. After a while you notice that some of the tests aren't passing. You back out your changes and the tests still won't pass! How is this possible? You know you've configured GitHub to protect the `master` branch so it can't be changed without passing tests and this shouldn't happen. The problem is that you haven't brewed your morning tea yet and you forgot to type `npm install` after `git pull`. Your `package.json` file and `node_modules` directory are out of sync. Oops! ## The Solution ```shell $ npm install --save-dev sync-modules ``` That's it; no configuration necessary. Installing the `sync-modules` package installs Git hooks to keep your `node_modules` directory in sync automatically with `package.json` when Git changes it. It won't install if you already have a `post-checkout` or `post-merge` Git hook defined. I welcome a pull request if this case is important to you. ## Credit Thanks to David Walsh for [the inspiration](https://davidwalsh.name/git-hook-npm-install-package-json-modified). ## Copyright Copyright 2016 David Braun This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.