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