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