UNPKG

1.8 kBMarkdownView Raw
1# on-change
2
3[![npm](https://img.shields.io/npm/dw/@olegjs/on-change)](https://www.npmjs.com/package/@olegjs/on-change)
4[![install size](https://packagephobia.now.sh/badge?p=@olegjs/on-change)](https://packagephobia.now.sh/result?p=@olegjs/on-change)
5![Node.js CI](https://github.com/olegjs/on-change/workflows/Node.js%20CI/badge.svg)
6[![Coverage Status](https://coveralls.io/repos/github/olegjs/on-change/badge.svg?branch=master)](https://coveralls.io/github/olegjs/on-change?branch=master)
7![GitHub last commit](https://img.shields.io/github/last-commit/olegjs/on-change)
8
9CLI tool to run a command if file has changed since the last time that command
10was run.
11
12Forgetting to run `npm i` or `npm ci` every time after `git pull` or switching
13between branches and getting `Error: Cannot find module...`? Add the following
14to `package.json` to automate this chore.
15
16```json
17"scripts": {
18 "prestart": "npx @olegjs/on-change --file package-lock.json npm ci"
19}
20```
21
22This CLI tool stores a file checksum in a hidden `sha` file every time it run a
23given command. Made to automate running `npm ci` after pulling modified
24`package-lock.json`.
25
26## Install
27
28```sh
29npm install --save-dev @olegjs/on-change
30```
31
32## Usage
33
34```sh
35npx @olegjs/on-change --help
36
37# Usage: on-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# --color Force color or disable with --no-color [boolean]
44#
45# Examples:
46# on-change --file package-lock.json npm Reinstall dependencies on changed
47# ci package-lock.json
48```