# run-on-change

> Run something on file change

Latest version **0.1.6** (published 2022-02-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install run-on-change
pnpm add run-on-change
yarn add run-on-change
bun add run-on-change
```

Provides the command `run-on-change`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.6 |
| Published | 2022-02-09 |
| First published | 2019-08-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | mjy9088 |
| Maintainers | mjy9088 |

## Links

- npm: https://www.npmjs.com/package/run-on-change
- Repository: https://github.com/mjy9088/run-on-change
- Homepage: https://github.com/mjy9088/run-on-change#readme
- Issues: https://github.com/mjy9088/run-on-change/issues
- npm.io page: https://npm.io/package/run-on-change

## Dependencies (1)

- [minimist](https://npm.io/package/minimist.md) ^1.2.0

## Recent versions

- 0.1.6 (latest) — 2022-02-09
- 0.1.5 — 2019-09-07
- 0.1.4 — 2019-09-07
- 0.1.3 — 2019-09-07
- 0.1.2 — 2019-09-07
- 0.1.1 — 2019-09-07
- 0.1.0 — 2019-09-05
- 0.0.9 — 2019-09-04
- 0.0.8 — 2019-09-04
- 0.0.7 — 2019-08-28
- 0.0.6 — 2019-08-26
- 0.0.5 — 2019-08-26
- 0.0.4 — 2019-08-24
- 0.0.3 — 2019-08-24
- 0.0.2 — 2019-08-24
- … 1 more at https://npm.io/package/run-on-change/versions

## README

# run-on-change

Run given command on file change

## Installation

```bash
npm install --save-dev run-on-change
```

## Usage example

Create file `run-on-change.json` for the project (example below)

```json
[
    [
        [["babel", "--plugins", "transform-react-jsx", 1], 0],
        {
            "type": "text",
            "file": "list.txt",
            "filter" : ["%sx", 0]
        }
    ]
]
```

and run

```bash
npx run-on-change
```

It will automatically transpile the jsx file **on file changes** (listed in `list.txt`)

When you want to **run all once** without file changes, use `--init` option.

```bash
git clone (URL)
npm install
npx run-on-change --init
```

it's useful when each script folder's `.gitignore` lists js files

## run-on-change.json

`run-on-change.json` specifies what to run on which file changes.

The `run-on-changing.json` file consists of a single array of array.

Each array's first element is commands array, and rests are files.
If file is object with `{type: "text"}`, It will watch all files listed in the `file`.

Each elements of commands array are command array or file.
First element of command array is actual command, rests are parameters

To pass file name or etc..., pass number instead of string as parameter.
0 to specified file name, 1 to actual file name, 2 to absolute path, ...

String formatting is also supported. pass array instead of string as parameter.
First element is format, rests are arguments. It uses `util.format`.



## Release History

Please don't use `0.1.1` and `0.1.3`

- `0.1.6`: fix bug

No plan to document & support older versions *under `1.0.0`*

---
_Source: https://npm.io/package/run-on-change · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
