<commit_before># wtch

[![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)

A small command-line app that watches for file changes and triggers a live-reload on file save (to be used with the [LiveReload plugin](https://chrome.google.com/webstore/detail/livereload/jnihajbhpnppcggbcgedagnkighmdlei?hl=en)). Watches the current working directory for `js,html,css` file changes. Ignores `.git`, `node_modules` and `bower_components` folders. 

```sh
npm install wtch -g

#start watching ..
wtch
```

You can use [garnish](https://github.com/mattdesl/garnish) for pretty-printing logs and limiting log level. 

```js
wtch | garnish --level debug
```

See [setup](#setup) for a basic how-to, and [tooling](#Tooling) for more advanced uses with browserify, watchify, etc.

PRs/suggestions welcome.

## Usage

[![NPM](https://nodei.co/npm/wtch.png)](https://www.npmjs.com/package/wtch)

```sh
Usage:
    wtch [globs] [opts]

Options:
    --dir -d        current working directory to watch (defaults to cwd)
    --extension -e  specifies an extension or a comma-separated list (default js,css,html)
    --event         the type of event to watch, "all" or "change" (default "change")
    --port -p       the port to run livereload (defaults to 35729)
    --poll          enable polling for file watching
```

By default, it looks for `**/*` with the specified extensions. If `globs` is specified, they will *override* this behaviour. So you can do this to only watch a single file:

```
wtch bundle.js
```

## API

#### `wtch(glob, [opt, cb])`

Returns a through stream that watches the glob (or array of globs) with the given options and an optional callback when LiveReload is listening.

Supported options:

- `cwd` the current working directory for chokidar
- `poll` whether to use polling, default false
- `event` the type of event to watch, can be `"change"` (default, only file save) or `"all"` (remove/delete/etc)
- `port` the port for livereload, defaults to 35729

## Setup

First, install the LiveReload plugin for your browser of choice (e.g. [Chrome](https://chrome.google.com/webstore/detail/livereload/jnihajbhpnppcggbcgedagnkighmdlei?hl=en)). 

Now, install some tools globally. 

```sh
npm install wtch http-server garnish -g
```

Create a basic `index.html` file that references scripts and/or CSS files.

Then, you can run your development server like so:

```sh
http-server | wtch | garnish
```

Enable LiveReload by clicking the plugin so the center of it turns black. You may need to refresh the page first.

![Click to enable](http://imgur.com/YdCgusY)<commit_msg>fixing image url<commit_after># wtch

[![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)

A small command-line app that watches for file changes and triggers a live-reload on file save (to be used with the [LiveReload plugin](https://chrome.google.com/webstore/detail/livereload/jnihajbhpnppcggbcgedagnkighmdlei?hl=en)). Watches the current working directory for `js,html,css` file changes. Ignores `.git`, `node_modules` and `bower_components` folders. 

```sh
npm install wtch -g

#start watching ..
wtch
```

You can use [garnish](https://github.com/mattdesl/garnish) for pretty-printing logs and limiting log level. 

```js
wtch | garnish --level debug
```

See [setup](#setup) for a basic how-to, and [tooling](#Tooling) for more advanced uses with browserify, watchify, etc.

PRs/suggestions welcome.

## Usage

[![NPM](https://nodei.co/npm/wtch.png)](https://www.npmjs.com/package/wtch)

```sh
Usage:
    wtch [globs] [opts]

Options:
    --dir -d        current working directory to watch (defaults to cwd)
    --extension -e  specifies an extension or a comma-separated list (default js,css,html)
    --event         the type of event to watch, "all" or "change" (default "change")
    --port -p       the port to run livereload (defaults to 35729)
    --poll          enable polling for file watching
```

By default, it looks for `**/*` with the specified extensions. If `globs` is specified, they will *override* this behaviour. So you can do this to only watch a single file:

```
wtch bundle.js
```

## API

#### `wtch(glob, [opt, cb])`

Returns a through stream that watches the glob (or array of globs) with the given options and an optional callback when LiveReload is listening.

Supported options:

- `cwd` the current working directory for chokidar
- `poll` whether to use polling, default false
- `event` the type of event to watch, can be `"change"` (default, only file save) or `"all"` (remove/delete/etc)
- `port` the port for livereload, defaults to 35729

## Setup

First, install the LiveReload plugin for your browser of choice (e.g. [Chrome](https://chrome.google.com/webstore/detail/livereload/jnihajbhpnppcggbcgedagnkighmdlei?hl=en)). 

Now, install some tools globally. 

```sh
npm install wtch http-server garnish -g
```

Create a basic `index.html` file that references scripts and/or CSS files.

Then, you can run your development server like so:

```sh
http-server | wtch | garnish
```

Enable LiveReload by clicking the plugin so the center of it turns black. You may need to refresh the page first.

![Click to enable](http://i.imgur.com/YdCgusY.png)
{'fraction_non_alphanumeric': 0.11793611793611794, 'fraction_numerical': 0.00378000378000378, 'mean_word_length': 4.016113744075829, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 10, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3415279', 'n_tokens_mistral': 1754, 'n_tokens_neox': 1634, 'n_words': 627}