-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check pattern existence before glob (#7587)
- Loading branch information
Showing
20 changed files
with
358 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#### Test whether passed globs are names of existing files before treating them as globs ([#7587](https://github.com/prettier/prettier/pull/7587) by [@fisker](https://github.com/fisker)) | ||
|
||
Since file names in Linux can contain almost any characters, strings like `foo*.js` and `[bar].css` are valid file names. Previously, if the user needed to format a file named `[bar].css`, a glob escaping syntax had to be used: `prettier "\[bar].css"` (this one doesn't work on Windows, where backslashes are treated as path separators) or `prettier "[[]bar].css"`. Because of this, important use cases were broken. E.g. [lint-staged](https://github.com/okonet/lint-staged) passes absolute paths and knows nothing about the escaping syntax. Now, when Prettier CLI gets a glob, it first tries to resolve it as a literal file name. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
tests_integration/__tests__/__snapshots__/patterns-glob.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`fixtures-1: Should match all files (stderr) 1`] = `""`; | ||
|
||
exports[`fixtures-1: Should match all files (stdout) 1`] = ` | ||
"!file.js | ||
a.js | ||
b.js | ||
" | ||
`; | ||
|
||
exports[`fixtures-1: Should match all files (write) 1`] = `Array []`; | ||
|
||
exports[`fixtures-1: Should match files except \`a.js\` (stderr) 1`] = `""`; | ||
|
||
exports[`fixtures-1: Should match files except \`a.js\` (stdout) 1`] = ` | ||
"!file.js | ||
b.js | ||
" | ||
`; | ||
|
||
exports[`fixtures-1: Should match files except \`a.js\` (write) 1`] = `Array []`; | ||
|
||
exports[`fixtures-2: Should match \`a.js\` and \`!b.js\` (stderr) 1`] = `""`; | ||
|
||
exports[`fixtures-2: Should match \`a.js\` and \`!b.js\` (stdout) 1`] = ` | ||
"!b.js | ||
a.js | ||
" | ||
`; | ||
|
||
exports[`fixtures-2: Should match \`a.js\` and \`!b.js\` (write) 1`] = `Array []`; | ||
|
||
exports[`fixtures-2: Should match all js files (stderr) 1`] = `""`; | ||
|
||
exports[`fixtures-2: Should match all js files (stdout) 1`] = ` | ||
"!b.js | ||
a.js | ||
" | ||
`; | ||
|
||
exports[`fixtures-2: Should match all js files (write) 1`] = `Array []`; | ||
|
||
exports[`fixtures-2: Should only match \`!b.js\` (stderr) 1`] = `""`; | ||
|
||
exports[`fixtures-2: Should only match \`!b.js\` (stdout) 1`] = ` | ||
"!b.js | ||
" | ||
`; | ||
|
||
exports[`fixtures-2: Should only match \`!b.js\` (write) 1`] = `Array []`; | ||
|
||
exports[`fixtures-3: Should exclude \`.svn\` (stderr) 1`] = `""`; | ||
|
||
exports[`fixtures-3: Should exclude \`.svn\` (stdout) 1`] = ` | ||
"outside.js | ||
" | ||
`; | ||
|
||
exports[`fixtures-3: Should exclude \`.svn\` (write) 1`] = `Array []`; | ||
|
||
exports[`fixtures-3: Should match \`outside.js\`, \`dir/inside.js\` and \`dir/node_modules/in-node_modules.js\` (stderr) 1`] = `""`; | ||
|
||
exports[`fixtures-3: Should match \`outside.js\`, \`dir/inside.js\` and \`dir/node_modules/in-node_modules.js\` (stdout) 1`] = ` | ||
"dir/inside.js | ||
dir/node_modules/in-node_modules.js | ||
outside.js | ||
" | ||
`; | ||
|
||
exports[`fixtures-3: Should match \`outside.js\`, \`dir/inside.js\` and \`dir/node_modules/in-node_modules.js\` (write) 1`] = `Array []`; | ||
|
||
exports[`fixtures-3: Should only match \`outside.js\` and \`dir/inside.js\` (stderr) 1`] = `""`; | ||
|
||
exports[`fixtures-3: Should only match \`outside.js\` and \`dir/inside.js\` (stdout) 1`] = ` | ||
"dir/inside.js | ||
outside.js | ||
" | ||
`; | ||
|
||
exports[`fixtures-3: Should only match \`outside.js\` and \`dir/inside.js\` (write) 1`] = `Array []`; | ||
|
||
exports[`fixtures-4: Should match \`level-1.js\` #2 (stderr) 1`] = `""`; | ||
|
||
exports[`fixtures-4: Should match \`level-1.js\` #2 (stdout) 1`] = ` | ||
"0/level-1.js | ||
" | ||
`; | ||
|
||
exports[`fixtures-4: Should match \`level-1.js\` #2 (write) 1`] = `Array []`; | ||
|
||
exports[`fixtures-4: Should match \`level-1.js\` #3 (stderr) 1`] = `""`; | ||
|
||
exports[`fixtures-4: Should match \`level-1.js\` #3 (stdout) 1`] = ` | ||
"0/level-1.js | ||
" | ||
`; | ||
|
||
exports[`fixtures-4: Should match \`level-1.js\` #3 (write) 1`] = `Array []`; | ||
|
||
exports[`fixtures-4: Should match \`level-1.js\` (stderr) 1`] = `""`; | ||
|
||
exports[`fixtures-4: Should match \`level-1.js\` (stdout) 1`] = ` | ||
"0/level-1.js | ||
" | ||
`; | ||
|
||
exports[`fixtures-4: Should match \`level-1.js\` (write) 1`] = `Array []`; |
Oops, something went wrong.