1 | # on-change
|
2 |
|
3 | [![Build Status](https://travis-ci.org/olegjs/on-change.svg?branch=master)](https://travis-ci.org/olegjs/on-change)
|
4 | [![Coverage Status](https://coveralls.io/repos/github/olegjs/on-change/badge.svg?branch=master)](https://coveralls.io/github/olegjs/on-change?branch=master)
|
5 | [![dependencies Status](https://david-dm.org/olegjs/on-change/status.svg)](https://david-dm.org/olegjs/on-change)
|
6 | [![devDependencies Status](https://david-dm.org/olegjs/on-change/dev-status.svg)](https://david-dm.org/olegjs/on-change?type=dev)
|
7 | ![GitHub last commit](https://img.shields.io/github/last-commit/olegjs/on-change)
|
8 |
|
9 | CLI tool to run a command if file has changed since the last time that command
|
10 | was run.
|
11 |
|
12 | Forgetting to run `npm i` every time after `git pull` and getting
|
13 | `Error: Cannot find module...`? Add the following to `package.json` to automate
|
14 | this chore.
|
15 |
|
16 | ```json
|
17 | {
|
18 | "scripts": {
|
19 | "prestart": "on-change --file package-lock.json npm ci"
|
20 | }
|
21 | }
|
22 | ```
|
23 |
|
24 | This CLI tool stores a file checksum in a hidden `sha` file every time it run a
|
25 | given command. Made to automate running `npm ci` after pulling modified
|
26 | `package-lock.json`.
|
27 |
|
28 | ## Install
|
29 |
|
30 | ```sh
|
31 | npm install --save-dev @olegjs/on-change
|
32 | ```
|
33 |
|
34 | ## Usage
|
35 |
|
36 | ```sh
|
37 | npx @olegjs/on-change --help
|
38 | # Usage: on-file-change --file [file] [command]
|
39 | #
|
40 | # Options:
|
41 | # --help Show help [boolean]
|
42 | # --version Show version number [boolean]
|
43 | # --file, -f Path to file to check for changes [string] [required]
|
44 | #
|
45 | # Examples:
|
46 | # on-file-change --file package-lock.json Reinstall dependencies on changed
|
47 | # npm ci package-lock.json
|
48 | ```
|