diff --git a/src/cli-util.js b/src/cli-util.js index 50e401b95..27c0494d2 100644 --- a/src/cli-util.js +++ b/src/cli-util.js @@ -281,7 +281,7 @@ function eachFilename(argv, patterns, callback) { try { const filePaths = globby - .sync(patterns, { dot: true }) + .sync(patterns, { dot: true, nodir: true }) .map(filePath => path.relative(process.cwd(), filePath)); if (filePaths.length === 0) { diff --git a/tests_integration/__tests__/__snapshots__/skip-folders.js.snap b/tests_integration/__tests__/__snapshots__/skip-folders.js.snap new file mode 100644 index 000000000..26593103d --- /dev/null +++ b/tests_integration/__tests__/__snapshots__/skip-folders.js.snap @@ -0,0 +1,17 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`skip folders passed specifically (stdout) 1`] = ` +"a/file.js +b/file.js +" +`; + +exports[`skip folders passed specifically (write) 1`] = `Array []`; + +exports[`skips folders in glob (stdout) 1`] = ` +"a/file.js +b/file.js +" +`; + +exports[`skips folders in glob (write) 1`] = `Array []`; diff --git a/tests_integration/__tests__/skip-folders.js b/tests_integration/__tests__/skip-folders.js new file mode 100644 index 000000000..a2403bbf8 --- /dev/null +++ b/tests_integration/__tests__/skip-folders.js @@ -0,0 +1,22 @@ +"use strict"; + +const runPrettier = require("../runPrettier"); + +expect.addSnapshotSerializer(require("../path-serializer")); + +describe("skips folders in glob", () => { + runPrettier("cli/skip-folders", ["**/*", "-l"]).test({ + status: 1, + stderr: "" + }); +}); + +describe("skip folders passed specifically", () => { + runPrettier("cli/skip-folders", [ + "a", + "a/file.js", + "b", + "b/file.js", + "-l" + ]).test({ status: 1, stderr: "" }); +}); diff --git a/tests_integration/cli/skip-folders/a/file.js b/tests_integration/cli/skip-folders/a/file.js new file mode 100644 index 000000000..d785a6ad8 --- /dev/null +++ b/tests_integration/cli/skip-folders/a/file.js @@ -0,0 +1 @@ +fooA( ) diff --git a/tests_integration/cli/skip-folders/b/file.js b/tests_integration/cli/skip-folders/b/file.js new file mode 100644 index 000000000..2fc0b7efc --- /dev/null +++ b/tests_integration/cli/skip-folders/b/file.js @@ -0,0 +1 @@ +fooB( )