1.0.6 • Published 1 year ago

prettier-cli-watcher v1.0.6

Weekly downloads
24
License
MIT
Repository
github
Last release
1 year ago

prettier-cli-watcher

Runs prettier from CLI on project files when modified.

Install

Locally per project:

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

Or globally:

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

How To Use

$ prettier-cli-watcher

Or use a package.json script:

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

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

Options

  • --dir: The absolute path of directory to watch (default: process.cwd()).
  • --config: The project's prettier config is automatically located and used via cosmiconfig.
    • Or provide the file's absolute path or relative path to --dir.
  • --ignore: Like the prettier config, the project's .prettierignore 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 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.

Configuration Files

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 is looked for at the following locations. By default the entire --dir directory is watched so ensure to use a .prettierignore file to ignore paths like node_modules/, .git/, and dist/, for example.

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

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).

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.

Attribution

License

This project uses the MIT License.

1.0.6

1 year ago

1.0.5

3 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.3.6

4 years ago

0.3.5

4 years ago

0.3.4

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.9

5 years ago

0.2.8

5 years ago

0.2.7

5 years ago

0.2.6

5 years ago

0.1.5

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago