# prettier-cli-watcher

> Runs prettier from CLI on project file(s) when modified.

Latest version **1.0.6** (published 2023-01-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install prettier-cli-watcher
pnpm add prettier-cli-watcher
yarn add prettier-cli-watcher
bun add prettier-cli-watcher
```

Provides the command `prettier-cli-watcher`.

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2023-01-14 |
| First published | 2018-12-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8.14.0 |
| Dependencies | 17 |
| Unpacked size | 109.4 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Carlos Gabriel |
| Maintainers | cgabriel5 |
| Keywords | prettier, cli, watcher |

## Links

- npm: https://www.npmjs.com/package/prettier-cli-watcher
- Repository: https://github.com/cgabriel5/prettier-cli-watcher
- Homepage: https://github.com/cgabriel5/prettier-cli-watcher#readme
- Issues: https://github.com/cgabriel5/prettier-cli-watcher/issues
- npm.io page: https://npm.io/package/prettier-cli-watcher

## Dependencies (17)

- [temp](https://npm.io/package/temp.md) ^0.9.4
- [toml](https://npm.io/package/toml.md) ^3.0.0
- [chalk](https://npm.io/package/chalk.md) 4.1.2
- [hound](https://npm.io/package/hound.md) ^1.0.5
- [slash](https://npm.io/package/slash.md) ^3.0.0
- [upath](https://npm.io/package/upath.md) ^2.0.1
- [flatry](https://npm.io/package/flatry.md) ^1.0.12
- [ignore](https://npm.io/package/ignore.md) 5.2.4
- [chokidar](https://npm.io/package/chokidar.md) 3.5.3
- [minimist](https://npm.io/package/minimist.md) 1.2.7
- [tree-kill](https://npm.io/package/tree-kill.md) ^1.2.2
- [cosmiconfig](https://npm.io/package/cosmiconfig.md) 7.1.0
- [file-exists](https://npm.io/package/file-exists.md) ^5.0.1
- [node-notifier](https://npm.io/package/node-notifier.md) ^9.0.1
- [parse-gitignore](https://npm.io/package/parse-gitignore.md) ^1.0.1
- [directory-exists](https://npm.io/package/directory-exists.md) ^2.0.1
- [cross-spawn-with-kill](https://npm.io/package/cross-spawn-with-kill.md) ^1.0.0

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 1.0.6 (latest) — 2023-01-14
- 1.0.5 — 2021-03-15
- 1.0.4 — 2020-07-27
- 1.0.3 — 2020-07-18
- 1.0.2 — 2020-07-18
- 1.0.1 — 2020-05-17
- 1.0.0 — 2020-05-08
- 0.3.6 — 2020-04-10
- 0.3.5 — 2019-11-12
- 0.3.4 — 2019-07-13
- 0.3.3 — 2019-05-09
- 0.3.2 — 2019-05-09
- 0.3.1 — 2019-01-10
- 0.3.0 — 2019-01-07
- 0.2.9 — 2019-01-03
- … 9 more at https://npm.io/package/prettier-cli-watcher/versions

## README

# prettier-cli-watcher

Runs [prettier](https://github.com/prettier/prettier) from CLI on project files when modified.

<!-- <img src="/src/assets/img/example-output.png" width="65%"> -->

<a name="install"></a>

### Install

Locally per project:

```sh
$ npm install prettier-cli-watcher --save-dev
# or
$ yarn add prettier-cli-watcher --dev
```

Or globally:

```sh
$ sudo npm install -g prettier-cli-watcher
# or
$ yarn global add prettier-cli-watcher
```

<a name="how-to-use"></a>

### How To Use

```sh
$ prettier-cli-watcher
```

Or use a `package.json` script:

```json
...
"scripts": {
  "pretty": "prettier-cli-watcher"
}
...
```

Then run via `$ npm run pretty` or `$ yarn run pretty`.

<a name="options"></a>

### Options

- `--dir`: The absolute path of directory to watch (default: `process.cwd()`).
- `--config`: The project's prettier config is automatically [located](#configfiles) and used via [cosmiconfig](https://github.com/davidtheclark/cosmiconfig).
  - Or provide the file's absolute path or relative path to `--dir`.
- `--ignore`: Like the prettier config, the project's [`.prettierignore`](https://prettier.io/docs/en/ignore.html#ignoring-files) file is also located and used.
  - Or provide the file's absolute path or relative path to `--dir`.
  - **Note:** By default the entire `--dir` directory is watched. Make sure to use a [`.prettierignore`](https://prettier.io/docs/en/ignore.html#ignoring-files) file to ignore paths like `node_modules/`, `.git/`, and `dist/`, for example.
- `--notify`: Enable OS notifications when prettier errors.
- `--quiet`: Disable output.
- `--setup`: List setup details.
- `--dry`: Run prettier without saving changes (for ignore test runs).
- `--version`: List prettier-cli-watcher version.
<!-- - `--dtime`: Deflection time in milliseconds (default: `500`). -->

<!-- - `--watcher`: File watcher to use (default: [`chokidar`](https://github.com/paulmillr/chokidar), or [`hound`](https://github.com/gforceg/node-hound)). -->

<a name="configfiles"></a>

### Configuration Files

<details><summary>Expand section</summary>

<br>

[cosmiconfig](https://github.com/davidtheclark/cosmiconfig) is used to locate the project's prettier configuration file if one is not explicitly provided. Going from top to bottom, the following places are searched until a prettier configuration file is found. If one is not found the default prettier settings are used.

```
[
  'package.json',
  '.prettierrc',
  'configs/.prettierrc',
  '.prettierrc.json',
  'configs/.prettierrc.json',
  '.prettierrc.yaml',
  'configs/.prettierrc.yaml',
  '.prettierrc.yml',
  'configs/.prettierrc.yml',
  '.prettierrc.js',
  'configs/.prettierrc.js',
  'prettier.config.js',
  'configs/prettier.config.json',
  'configs/prettier.config.js',
  '.prettierrc.toml',
  'configs/.prettierrc.toml'
]
```

Likewise, the project's [`.prettierignore`](https://prettier.io/docs/en/ignore.html#ignoring-files) is looked for at the following locations. By default the entire `--dir` directory is watched so ensure to use a [`.prettierignore`](https://prettier.io/docs/en/ignore.html#ignoring-files) file to ignore paths like `node_modules/`, `.git/`, and `dist/`, for example.

```
[
  '.prettierignore',
  'configs/.prettierignore',
  'configs/prettierignore'
]
```

</details>

<a name="os-support"></a>

### OS Support

- Made using Node.js `v8.14.0` on a Linux machine running `Ubuntu 16.04.5 LTS`.
- Tested and working on:
  - `macOS High Sierra (v10.13)`.
  - `Windows 10 (v1703 OS Build: 15063.674)`.

<a name="contributing"></a>

### Contributing

Contributions are welcome! Found a bug, feel like documentation is lacking/confusing and needs an update, have performance/feature suggestions or simply found a typo? Let me know! :)

See how to contribute [here](/CONTRIBUTING.md).

<a name="attribution"></a>

### Attribution

- <div>
    The error notification icon was made by
    <a href="https://www.flaticon.com/authors/roundicons" title="Roundicons">
      Roundicons
    </a>
    from
    <a href="https://www.flaticon.com/" title="Flaticon">
      www.flaticon.com
    </a>
    and is licensed under
    <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">
      CC 3.0 BY</a>.
  </div>

<a name="license"></a>

### License

This project uses the [MIT License](/LICENSE.txt).

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