Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle long globs #16233

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog_unreleased/cli/16115.md
@@ -0,0 +1,3 @@
#### Don’t expand globs via symbolic links (#16115 by @jsoref)

Prettier can now handle long globs.
2 changes: 1 addition & 1 deletion src/cli/utils.js
Expand Up @@ -78,7 +78,7 @@ async function lstatSafe(filePath) {
return await fs.lstat(filePath);
} catch (/** @type {any} */ error) {
/* c8 ignore next 3 */
if (error.code !== "ENOENT") {
if (error.code !== "ENOENT" && error.code !== "ENAMETOOLONG") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how it will work if it's not a glob pattern. Maybe we should not ignore it?

isDynamicPattern can be useful.

throw error;
}
}
Expand Down
Expand Up @@ -99,3 +99,9 @@ exports[`should not ignore file paths contains object prototype keys (stderr) 1`
exports[`should not ignore file paths contains object prototype keys (stdout) 1`] = `"constructor/should-be-formatted.js"`;

exports[`should not ignore file paths contains object prototype keys (write) 1`] = `[]`;

exports[`fixtures-6: should handle very long globs (stderr) 1`] = `""`;

exports[`fixtures-6: should handle very long globs (stdout) 1`] = `""`;

exports[`fixtures-6: should handle very long globs (write) 1`] = `[]`;
13 changes: 13 additions & 0 deletions tests/integration/__tests__/patterns-glob.js
Expand Up @@ -134,3 +134,16 @@ describe("should not ignore file paths contains object prototype keys", () => {
"-l",
]).test({ status: 1 });
});

describe("fixtures-6: should handle very long globs", () => {
const files = [];
let file = "a";
for (let i = 1 ; i < 9 ; ++i) {
const fileName = file + ".json";
files.push(fileName);
file += file;
}
runCli("cli/patterns-glob/fixtures-6", [
"{" + files.join(",") + "}"
]).test({ status: 0 });
});
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.