UNPKG

1.71 kBMarkdownView Raw
1# on-change
2
3[![Build Status](https://travis-ci.org/olegjs/on-change.svg?branch=master)](https://travis-ci.org/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[![dependencies Status](https://david-dm.org/olegjs/on-change/status.svg)](https://david-dm.org/olegjs/on-change)
6[![devDependencies Status](https://david-dm.org/olegjs/on-change/dev-status.svg)](https://david-dm.org/olegjs/on-change?type=dev)
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` every time after `git pull` and getting
13`Error: Cannot find module...`? Add the following to `package.json` to automate
14this chore.
15
16```json
17{
18 "scripts": {
19 "prestart": "on-change --file package-lock.json npm ci"
20 }
21}
22```
23
24This CLI tool stores a file checksum in a hidden `sha` file every time it run a
25given command. Made to automate running `npm ci` after pulling modified
26`package-lock.json`.
27
28## Install
29
30```sh
31npm install --save-dev @olegjs/on-change
32```
33
34## Usage
35
36```sh
37npx @olegjs/on-change --help
38# Usage: on-file-change --file [file] [command]
39#
40# Options:
41# --help Show help [boolean]
42# --version Show version number [boolean]
43# --file, -f Path to file to check for changes [string] [required]
44#
45# Examples:
46# on-file-change --file package-lock.json Reinstall dependencies on changed
47# npm ci package-lock.json
48```