Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Apr 3, 2023
1 parent a3e5146 commit 3aa1890
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 24 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ Supports these glob features:
- [Posix character
classes](https://www.gnu.org/software/bash/manual/html_node/Pattern-Matching.html),
like `[[:alpha:]]`, supporting the full range of Unicode
characters. For example, `[[:alpha:]]` will match against
`'é'`, though `[a-zA-Z]` will not. Collating symbol and set
characters. For example, `[[:alpha:]]` will match against
`'é'`, though `[a-zA-Z]` will not. Collating symbol and set
matching is not supported, so `[[=e=]]` will _not_ match `'é'`
and `[[.ch.]]` will not match `'ch'` in locales where `ch` is
considered a single character.
Expand Down Expand Up @@ -131,19 +131,19 @@ var mm = new Minimatch(pattern, options)
method is mainly for internal use, but is exposed so that it can be
used by a glob-walker that needs to avoid excessive filesystem calls.
- `hasMagic()` Returns true if the parsed pattern contains any
magic characters. Returns false if all comparator parts are
string literals. If the `magicalBraces` option is set on the
magic characters. Returns false if all comparator parts are
string literals. If the `magicalBraces` option is set on the
constructor, then it will consider brace expansions which are
not otherwise magical to be magic. If not set, then a pattern
not otherwise magical to be magic. If not set, then a pattern
like `a{b,c}d` will return `false`, because neither `abd` nor
`acd` contain any special glob characters.

This does **not** mean that the pattern string can be used as a
literal filename, as it may contain magic glob characters that
are escaped. For example, the pattern `\\*` or `[*]` would not
are escaped. For example, the pattern `\\*` or `[*]` would not
be considered to have magic, as the matching portion parses to
the literal string `'*'` and would match a path named `'*'`,
not `'\\*'` or `'[*]'`. The `minimatch.unescape()` method may
not `'\\*'` or `'[*]'`. The `minimatch.unescape()` method may
be used to remove escape characters.

All other methods are internal, and will be called as necessary.
Expand Down Expand Up @@ -182,7 +182,7 @@ be escaped or unescaped.
Un-escape a glob string that may contain some escaped characters.

If the `windowsPathsNoEscape` option is used, then square-brace
escapes are removed, but not backslash escapes. For example, it
escapes are removed, but not backslash escapes. For example, it
will turn the string `'[*]'` into `*`, but it will not turn
`'\\*'` into `'*'`, because `\` is a path separator in
`windowsPathsNoEscape` mode.
Expand Down Expand Up @@ -261,7 +261,7 @@ This only affects the results of the `Minimatch.hasMagic` method.

If the pattern contains brace expansions, such as `a{b,c}d`, but
no other magic characters, then the `Minipass.hasMagic()` method
will return `false` by default. When this option set, it will
will return `false` by default. When this option set, it will
return `true` for brace expansion as well as other magic glob
characters.

Expand Down
4 changes: 2 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@

- Add `optimizationLevel` configuration option, and revert the
default back to the 6.2 style minimal optimizations, making the
advanced transforms introduced in 7.0 opt-in. Also, process
advanced transforms introduced in 7.0 opt-in. Also, process
provided file paths in the same way in optimizationLevel:2
mode, so _most_ things that matched with optimizationLevel 1 or
0 _should_ match with level 2 as well. However, level 1 is the
0 _should_ match with level 2 as well. However, level 1 is the
default, out of an abundance of caution.

## 7.0
Expand Down
10 changes: 7 additions & 3 deletions test/escape-has-magic.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ for (const p of patterns) {
const escapep = escape(pattern)
const escapew = escape(pattern, { windowsPathsNoEscape: true })
t.equal(unescape(escapep), pattern, 'posix unescape(' + pattern + ')')
t.equal(unescape(escapew, {
windowsPathsNoEscape: true,
}), pattern, 'win32 unescape(' + pattern + ')')
t.equal(
unescape(escapew, {
windowsPathsNoEscape: true,
}),
pattern,
'win32 unescape(' + pattern + ')'
)
const mmp = new Minimatch(escapep, { ...opts, nocaseMagicOnly: true })
const mmw = new Minimatch(escapew, {
...opts,
Expand Down
26 changes: 16 additions & 10 deletions test/windows-no-magic-root.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Minimatch} from '../'
import { Minimatch } from '../'
import t from 'tap'

t.test('no magic the root', t => {
Expand All @@ -16,15 +16,21 @@ t.test('no magic the root', t => {
t.plan(patterns.length)
for (const p of patterns) {
t.test(p, t => {
t.matchSnapshot(new Minimatch(p, {
platform: 'win32',
nocase: true,
}).set, 'default to true')
t.matchSnapshot(new Minimatch(p, {
windowsNoMagicRoot: false,
platform: 'win32',
nocase: true,
}).set, 'set explicitly false')
t.matchSnapshot(
new Minimatch(p, {
platform: 'win32',
nocase: true,
}).set,
'default to true'
)
t.matchSnapshot(
new Minimatch(p, {
windowsNoMagicRoot: false,
platform: 'win32',
nocase: true,
}).set,
'set explicitly false'
)
t.end()
})
}
Expand Down

0 comments on commit 3aa1890

Please sign in to comment.