diff --git a/README.md b/README.md index b20dc529c..6df23bdc4 100644 --- a/README.md +++ b/README.md @@ -244,14 +244,14 @@ Another useful flag is `--list-different` (or `-l`) which prints the filenames o prettier --single-quote --list-different "src/**/*.js" ``` -#### `--resolve-config` and `--config` +#### `--find-config-path` and `--config` If you are repeatedly formatting individual files with `prettier`, you will incur a small performance cost when prettier attempts to look up a [configuration file](#configuration-file). In order to skip this, you may ask prettier to find the config file once, and re-use it later on. ```bash -prettier --resolve-config ./my/file.js +prettier --find-config-path ./my/file.js ./my/.prettierrc ``` diff --git a/bin/prettier.js b/bin/prettier.js index 34a5001ec..8318bcfee 100755 --- a/bin/prettier.js +++ b/bin/prettier.js @@ -56,7 +56,7 @@ const argv = minimist(args, { "range-end", "stdin-filepath", "config", - "resolve-config", + "find-config-path", "ignore-path" ], default: { @@ -102,8 +102,8 @@ if (write && argv["debug-check"]) { process.exit(1); } -if (argv["resolve-config"] && filepatterns.length) { - console.error("Cannot use --resolve-config with multiple files"); +if (argv["find-config-path"] && filepatterns.length) { + console.error("Cannot use --find-config-path with multiple files"); process.exit(1); } @@ -278,7 +278,7 @@ function handleError(filename, e) { if ( argv["help"] || - (!filepatterns.length && !stdin && !argv["resolve-config"]) + (!filepatterns.length && !stdin && !argv["find-config-path"]) ) { console.log( "Usage: prettier [opts] [filename ...]\n\n" + @@ -286,7 +286,9 @@ if ( " --write Edit the file in-place. (Beware!)\n" + " --list-different or -l Print filenames of files that are different from Prettier formatting.\n" + " --config Path to a prettier configuration file (.prettierrc, package.json, prettier.config.js).\n" + - " --resolve-config Resolve the path to a configuration file for a given input file.\n" + + " --no-config Do not look for a configuration file.\n" + + " --find-config-path \n" + + " Finds and prints the path to a configuration file for a given input file.\n" + " --ignore-path Path to a file containing patterns that describe files to ignore.\n" + " Defaults to ./.prettierignore.\n" + " --stdin Read input from stdin.\n" + @@ -320,8 +322,8 @@ if ( process.exit(argv["help"] ? 0 : 1); } -if (argv["resolve-config"]) { - resolveConfig(argv["resolve-config"]); +if (argv["find-config-path"]) { + resolveConfig(argv["find-config-path"]); } else if (stdin) { getStream(process.stdin).then(input => { getOptionsForFile(process.cwd()).then(options => { diff --git a/tests_integration/__tests__/__snapshots__/config-resolution.js.snap b/tests_integration/__tests__/__snapshots__/config-resolution.js.snap index 34befee4b..57d5acb37 100644 --- a/tests_integration/__tests__/__snapshots__/config-resolution.js.snap +++ b/tests_integration/__tests__/__snapshots__/config-resolution.js.snap @@ -63,7 +63,7 @@ function f() { " `; -exports[`resolves configuration file with --resolve-config file 1`] = ` +exports[`resolves configuration file with --find-config-path file 1`] = ` ".prettierrc " `; diff --git a/tests_integration/__tests__/config-resolution.js b/tests_integration/__tests__/config-resolution.js index 947d4688e..fab2fbaed 100644 --- a/tests_integration/__tests__/config-resolution.js +++ b/tests_integration/__tests__/config-resolution.js @@ -27,17 +27,17 @@ test("accepts configuration from --config", () => { expect(output.status).toEqual(0); }); -test("resolves configuration file with --resolve-config file", () => { +test("resolves configuration file with --find-config-path file", () => { const output = runPrettier("cli/config/", [ - "--resolve-config", + "--find-config-path", "no-config/file.js" ]); expect(output.stdout).toMatchSnapshot(); expect(output.status).toEqual(0); }); -test("prints nothing when no file found with --resolve-config", () => { - const output = runPrettier("cli/config/", ["--resolve-config", ".."]); +test("prints nothing when no file found with --find-config-path", () => { + const output = runPrettier("cli/config/", ["--find-config-path", ".."]); expect(output.stdout).toEqual(""); expect(output.status).toEqual(1); });