UNPKG

1.76 kBMarkdownView Raw
1# on-change
2
3![Travis (.org)](https://img.shields.io/travis/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![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/olegjs/on-change)
6[![install size](https://packagephobia.now.sh/badge?p=@olegjs/on-change)](https://packagephobia.now.sh/result?p=@olegjs/on-change)
7![David](https://img.shields.io/david/olegjs/on-change)
8![GitHub last commit](https://img.shields.io/github/last-commit/olegjs/on-change)
9![NPM](https://img.shields.io/npm/l/@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` every time after `git pull` and getting
15`Error: Cannot find module...`? Add the following to `package.json` to automate
16this chore.
17
18```json
19{
20 "scripts": {
21 "prestart": "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# Usage: on-file-change --file [file] [command]
41#
42# Options:
43# --help Show help [boolean]
44# --version Show version number [boolean]
45# --file, -f Path to file to check for changes [string] [required]
46#
47# Examples:
48# on-file-change --file package-lock.json Reinstall dependencies on changed
49# npm ci package-lock.json
50```