UNPKG

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