Skip to content

Commit

Permalink
refactor: rename --silent to --quiet
Browse files Browse the repository at this point in the history
  • Loading branch information
iiroj authored and okonet committed Jul 1, 2019
1 parent 18acd59 commit 275d996
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
26 changes: 13 additions & 13 deletions README.md
Expand Up @@ -41,25 +41,25 @@ See [Releases](https://github.com/okonet/lint-staged/releases)

## Command line flags

```
$ ./node_modules/.bin/lint-staged --help
Usage: lint-staged [options]
Options:
-V, --version output the version number
-c, --config [path] Configuration file path or package
-d, --debug Enable debug mode
-h, --help output usage information
```bash
$ npx lint-staged --help
Usage: lint-staged [options]

Options:
-V, --version output the version number
-c, --config [path] Path to configuration file
-x, --shell Use execa’s shell mode to execute linter commands
-q, --quiet Use Listr’s silent renderer
-d, --debug Enable debug mode
-h, --help output usage information
```

* **`--config [path]`**: This can be used to manually specify the `lint-staged` config file location. However, if the specified file cannot be found, it will error out instead of performing the usual search. You may pass a npm package name for configuration also.
* **`--shell`**: By default linter commands will be parsed for speed and security. This has the side-effect that regular shell scripts might not work as expected. You can skip parsing of commands with this option.
* **`--quiet`**: By default `lint-staged` will print progress status to console while running linters. Use this flag to supress all output, exept for linter scripts.
* **`--debug`**: Enabling the debug mode does the following:
* `lint-staged` uses the [debug](https://github.com/visionmedia/debug) module internally to log information about staged files, commands being executed, location of binaries, etc. Debug logs, which are automatically enabled by passing the flag, can also be enabled by setting the environment variable `$DEBUG` to `lint-staged*`.
* Use the [`verbose` renderer](https://github.com/SamVerschueren/listr-verbose-renderer) for `listr`.
* Do not pass `--silent` to npm scripts.

## Configuration

Expand Down
4 changes: 2 additions & 2 deletions index.js
Expand Up @@ -20,7 +20,7 @@ cmdline
.version(pkg.version)
.option('-c, --config [path]', 'Path to configuration file')
.option('-x, --shell', 'Use execa’s shell mode to execute linter commands')
.option('-s, --silent', 'Use Listr’s silent renderer')
.option('-q, --quiet', 'Use Listr’s silent renderer')
.option('-d, --debug', 'Enable debug mode')
.parse(process.argv)

Expand All @@ -30,4 +30,4 @@ if (cmdline.debug) {

debug('Running `lint-staged@%s`', pkg.version)

require('./src')(console, cmdline.config, !!cmdline.shell, !!cmdline.silent, !!cmdline.debug)
require('./src')(console, cmdline.config, !!cmdline.shell, !!cmdline.quiet, !!cmdline.debug)
6 changes: 3 additions & 3 deletions src/index.js
Expand Up @@ -47,14 +47,14 @@ function loadConfig(configPath) {
* @param {Function} logger
* @param {String} configPath
* @param {Boolean} shellMode Use execa’s shell mode to execute linter commands
* @param {Boolean} silentMode Use Listr’s silent renderer
* @param {Boolean} quietMode Use Listr’s silent renderer
* @param {Boolean} debugMode Enable debug mode
*/
module.exports = function lintStaged(
logger = console,
configPath,
shellMode = false,
silentMode = false,
quietMode = false,
debugMode = false
) {
debug('Loading config using `cosmiconfig`')
Expand All @@ -77,7 +77,7 @@ module.exports = function lintStaged(
debug('Normalized config:\n%O', config)
}

return runAll(config, shellMode, silentMode, debugMode)
return runAll(config, shellMode, quietMode, debugMode)
.then(() => {
debug('linters were executed successfully!')
// No errors, exiting with 0
Expand Down
6 changes: 3 additions & 3 deletions src/runAll.js
Expand Up @@ -25,14 +25,14 @@ const MAX_ARG_LENGTH =
* Executes all tasks and either resolves or rejects the promise
* @param config {Object}
* @param {Boolean} shellMode Use execa’s shell mode to execute linter commands
* @param {Boolean} silentMode Use Listr’s silent renderer
* @param {Boolean} quietMode Use Listr’s silent renderer
* @param {Boolean} debugMode Enable debug mode
* @returns {Promise}
*/
module.exports = async function runAll(
config,
shellMode = false,
silentMode = false,
quietMode = false,
debugMode = false
) {
debug('Running all linter scripts')
Expand Down Expand Up @@ -85,7 +85,7 @@ https://github.com/okonet/lint-staged#using-js-functions-to-customize-linter-com

const listrOptions = {
dateFormat: false,
renderer: (silentMode && 'silent') || (debugMode && 'verbose') || 'update'
renderer: (quietMode && 'silent') || (debugMode && 'verbose') || 'update'
}

// If all of the configured "linters" should be skipped
Expand Down
2 changes: 1 addition & 1 deletion test/index2.spec.js
Expand Up @@ -15,7 +15,7 @@ describe('lintStaged', () => {
Listr.mockClear()
})

it('should pass silent flag to Listr', async () => {
it('should pass quiet flag to Listr', async () => {
expect.assertions(1)
await lintStaged(
console,
Expand Down

0 comments on commit 275d996

Please sign in to comment.