샘플
minimatch 10.1.1: Handle comment prefixes, negation flags, basename matching, dotfiles, and globstar segments in minimatch
검증된 샘플 — npm minimatch 10.1.1: Handle comment prefixes, negation flags, basename matching, dotfiles, and globstar segments in minimatch. node 22 · linux…
sha256:3ae907b811ef9a96a655b6cdb6cbaf64b9acc9b816653b98a3ea8d76e57b190c
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 2
- 빌드한 서명 키
- 2
선언된 환경
node linux x64 node node npm
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:d91480838ac982c9 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-18 |
| node 22 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-18 |
케이스
HOW- 목표
- Handle comment prefixes, negation flags, basename matching, dotfiles, and globstar segments in minimatch
- 패키지
- 심벌
-
- minimatch
- 환경
- node
- 생성일
- 2026-08-18T00:17:47Z
컨트랙트
- assert minimatch treats leading hash characters as comments that match nothing by default, requiring nocomment or backslash escaping to match literal hashes
- assert negation patterns with leading exclamation marks invert matches by default, while flipNegate preserves positive matches and nonegate matches literal exclamation marks
- assert matchBase matches slash-less patterns against path basenames but is ignored when the pattern contains a slash
- assert dotfiles are excluded from wildcards and globstars by default unless explicitly matched or dot mode is enabled
- assert globstar matches zero or more directory levels when isolated between slashes but acts as a single wildcard when concatenated with other characters
파일
- NOTES.md
- csx.json
- package-lock.json
- package.json
- test/contract.mjs
소스
# Minimatch Pattern Semantics and Matching Options
## Search Result and Prior Samples
A query for `minimatch@10.1.1` returned sample `sha256:585ab2a8ea43909cb7e47145ba967133e7da688e33baa7e055319539c3675105`, which verified brace expansion, partial matching, magic detection, filtering, and escape utilities. This sample investigates a distinct set of pattern parsing behaviors and options in `minimatch`: leading hash comments, leading exclamation negation handling, `matchBase` behavior, dotfile filtering, and globstar segment isolation.
## Pinned Release
- `minimatch`: `10.1.1`
## Observed Behavior and Traps
1. **Leading Hash (`#`) Comment Interpretation**:
- By default, patterns starting with `#` are treated as comment lines and match nothing.
- For example, `minimatch('#header', '#header')` returns `false`.
- To match a filename starting with `#`, either the `nocomment: true` option must be passed or the hash must be escaped as `\#header`.
- A naive expectation that `#header` matches `#header` directly fails silently with a false negative (returning `false` instead of `true`).
2. **Negation (`!`), `flipNegate`, and `nonegate`**:
- A leading `!` negates the match outcome by default (`minimatch('app.js', '!*.js')` is `false`, `minimatch('app.txt', '!*.js')` is `true`).
- Enabling `flipNegate: true` returns `true` when the underlying pattern matches (`minimatch('app.js', '!*.js', { flipNegate: true })` returns `true`).
- Enabling `nonegate: true` treats `!` as a literal character rather than a negation prefix (`minimatch('!app.js', '!*.js', { nonegate: true })` returns `true`).
3. **`matchBase` Slash-less Restriction**:
- `matchBase: true` matches a pattern without slashes against the basename of a nested path (`minimatch('src/components/button.js', '*.js', { matchBase: true })` returns `true`).
- When `matchBase` is `false`, `*.js` only matches root-level files.
- If the pattern contains any slash (e.g. `components/*.js`), `matchBase` has no effect and matching evaluates against the full path from root.
4. **Dotfile Exclusion**:
- By default (`dot: false`), wildcard `*` and globstar `**` do not match leading dots in filenames or directory segments (`minimatch('.env', '*')` and `minimatch('src/.config/app.json', 'src/**/app.json')` return `false`).
- Matching dotfiles requires either explicit dot patterns (`.*`) or passing `dot: true`.
5. **Globstar Zero-Segment Matching and Isolation**:
- An isolated globstar `**` between slashes matches zero or more directory segments (`minimatch('src/index.js', 'src/**/index.js')` returns `true`).
- When `**` is concatenated with characters in a segment (e.g., `src/**index.js`), it behaves as a single wildcard `*` rather than crossing directory boundaries.
{"case":{"believed":"patterns starting with a hash character match literal hash-prefixed filenames by default","caseId":"case:sha256:37691ac51126f1ba0907f6fd5f07c83a874d9b195f79e991c8888418ee6d8bb5","contract":["assert minimatch treats leading hash characters as comments that match nothing by default, requiring nocomment or backslash escaping to match literal hashes","assert negation patterns with leading exclamation marks invert matches by default, while flipNegate preserves positive matches and nonegate matches literal exclamation marks","assert matchBase matches slash-less patterns against path basenames but is ignored when the pattern contains a slash","assert dotfiles are excluded from wildcards and globstars by default unless explicitly matched or dot mode is enabled","assert globstar matches zero or more directory levels when isolated between slashes but acts as a single wildcard when concatenated with other characters"],"goal":"Handle comment prefixes, negation flags, basename matching, dotfiles, and globstar segments in minimatch","kind":"HOW","packages":["pkg:npm/minimatch@10.1.1"],"schemaVersion":1,"symbols":["minimatch"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","ecosystem":"npm","executionContext":"node","language":"node","os":"linux","packageManager":"npm","runtime":"node","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/minimatch@10.1.1"],"schemaVersion":1,"symbols":["minimatch"],"verifierAdapter":"node-typescript@1"}
{
"name": "minimatch-contract",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "minimatch-contract",
"version": "1.0.0",
"dependencies": {
"minimatch": "10.1.1"
}
},
"node_modules/@isaacs/balanced-match": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/@isaacs/balanced-match/-/balanced-match-4.0.1.tgz",
"integrity": "sha512-yzMTt9lEb8Gv7zRioUilSglI0c0smZ9k5D65677DLWLtWJaXIS3CqcGyUFByYKlnUj6TkjLVs54fBl6+TiGQDQ==",
"license": "MIT",
"engines": {
"node": "20 || >=22"
}
},
"node_modules/@isaacs/brace-expansion": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/@isaacs/brace-expansion/-/brace-expansion-5.0.1.tgz",
"integrity": "sha512-WMz71T1JS624nWj2n2fnYAuPovhv7EUhk69R6i9dsVyzxt5eM3bjwvgk9L+APE1TRscGysAVMANkB0jh0LQZrQ==",
"license": "MIT",
"dependencies": {
"@isaacs/balanced-match": "^4.0.1"
},
"engines": {
"node": "20 || >=22"
}
},
"node_modules/minimatch": {
"version": "10.1.1",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.1.1.tgz",
"integrity": "sha512-enIvLvRAFZYXJzkCYG5RKmPfrFArdLv+R+lbQ53BmIMLIry74bjKzX6iHAm8WYamJkhSSEabrWN5D97XnKObjQ==",
"license": "BlueOak-1.0.0",
"dependencies": {
"@isaacs/brace-expansion": "^5.0.0"
},
"engines": {
"node": "20 || >=22"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
}
}
}
{
"name": "minimatch-contract",
"version": "1.0.0",
"type": "module",
"dependencies": {
"minimatch": "10.1.1"
}
}
import assert from 'node:assert/strict';
import { minimatch } from 'minimatch';
// 1. Comment handling: leading '#' is treated as a comment and matches nothing unless disabled or escaped
assert.strictEqual(minimatch('#header', '#header'), false);
assert.strictEqual(minimatch('#header', '#header', { nocomment: true }), true);
assert.strictEqual(minimatch('#header', '\\#header'), true);
// 2. Negation: leading '!' inverts match; flipNegate restores positive evaluation; nonegate treats '!' literally
assert.strictEqual(minimatch('app.js', '!*.js'), false);
assert.strictEqual(minimatch('app.txt', '!*.js'), true);
assert.strictEqual(minimatch('app.js', '!*.js', { flipNegate: true }), true);
assert.strictEqual(minimatch('!app.js', '!*.js', { nonegate: true }), true);
// 3. matchBase behavior: matches basenames only if pattern contains no slashes
assert.strictEqual(minimatch('src/components/button.js', '*.js'), false);
assert.strictEqual(minimatch('src/components/button.js', '*.js', { matchBase: true }), true);
assert.strictEqual(minimatch('src/components/button.js', 'components/*.js', { matchBase: true }), false);
// 4. Dotfile behavior: leading dot paths excluded by default unless explicitly matched or dot: true is passed
assert.strictEqual(minimatch('.env', '*'), false);
assert.strictEqual(minimatch('.env', '.*'), true);
assert.strictEqual(minimatch('src/.config/app.json', 'src/**/app.json'), false);
assert.strictEqual(minimatch('src/.config/app.json', 'src/**/app.json', { dot: true }), true);
// 5. Globstar behavior: '**' spans zero or more path segments only when isolated between slashes
assert.strictEqual(minimatch('src/index.js', 'src/**/index.js'), true);
assert.strictEqual(minimatch('src/nested/dir/index.js', 'src/**/index.js'), true);
assert.strictEqual(minimatch('src/a/b/index.js', 'src/**index.js'), false);