CodeSampleX

샘플

picomatch 4.0.5: Exclude files from a glob match when adding a "!pattern" to the array does nothing

검증된 샘플 — npm picomatch 4.0.5: Exclude files from a glob match when adding a "!pattern" to the array does nothing. node 22 · linux alpine/x64 · docker에서…

sha256:1f237974ca30ebdf73f738e63ce5542765b1b010d22af4bc14c3fa2534d65503

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
3
빌드한 서명 키
3
선언된 환경 node 22 linux x64 node 22 javascript npm

검증 실행 환경

환경 컨트랙트 단계 실행일
node 22 · linux alpine/x64 · docker ed25519:a2ec939a4c60e243 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1
2026-08-13
node 22 · linux alpine/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1
2026-08-17
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5…
2026-09-07

케이스

FIX
목표
Exclude files from a glob match when adding a "!pattern" to the array does nothing
패키지
심벌
  • picomatch
  • ignore
환경
node 22
생성일
2026-08-13T18:37:09Z

컨트랙트

  1. assert * stops at a path separator while ** crosses them
  2. assert dotfiles need dot:true
  3. assert an array of patterns is OR-ed, so a negated entry excludes nothing
  4. assert the ignore option is what actually excludes

파일

  • csx.json
  • package-lock.json
  • package.json
  • src/index.mjs
  • test/contract.mjs

소스 아티팩트 내려받기 (tar.gz)

소스

csx.json
{"case":{"caseId":"case:sha256:c73f0f62077ec10dd67cd4c65cdcb1adf0e514c52705172de7e326416e1bdb14","constraints":{"moduleSystem":"esm","runtime":"node"},"contract":["assert * stops at a path separator while ** crosses them","assert dotfiles need dot:true","assert an array of patterns is OR-ed, so a negated entry excludes nothing","assert the ignore option is what actually excludes"],"goal":"Exclude files from a glob match when adding a \"!pattern\" to the array does nothing","kind":"FIX","packages":["pkg:npm/picomatch@4.0.5"],"schemaVersion":1,"symbols":["picomatch","ignore"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","ecosystem":"npm","executionContext":"node","language":"javascript","moduleSystem":"esm","os":"linux","packageManager":"npm","runtime":"node","runtimeVersion":"22","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/picomatch@4.0.5"],"schemaVersion":1,"symbols":["picomatch","ignore"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "csx-sample-picomatch-glob-match",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "csx-sample-picomatch-glob-match",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "picomatch": "4.0.5"
      }
    },
    "node_modules/picomatch": {
      "version": "4.0.5",
      "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.5.tgz",
      "integrity": "sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A==",
      "license": "MIT",
      "engines": {
        "node": ">=12"
      },
      "funding": {
        "url": "https://github.com/sponsors/jonschlinkert"
      }
    }
  }
}
package.json
{
  "name": "csx-sample-picomatch-glob-match",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "license": "MIT-0",
  "dependencies": {
    "picomatch": "4.0.5"
  }
}
src/index.mjs
import picomatch from 'picomatch';

// Three rules cause most glob surprises here:
//   1. `*` stops at a path separator; `**` crosses them.
//   2. Dotfiles are NOT matched unless dot:true, so "src/**/*.js" misses
//      "src/.config/a.js".
//   3. An ARRAY of patterns is OR-ed. Adding "!**/*.test.js" to the array
//      therefore excludes nothing — the file still matches the positive
//      pattern, so the result is true. Exclusion needs the `ignore`
//      option (or a lone negated pattern, which inverts by itself).
export function matcher(pattern, options = {}) {
  return picomatch(pattern, options);
}

// The correct way to say "these, except those".
export function matcherExcluding(pattern, ignore) {
  return picomatch(pattern, { ignore });
}
test/contract.mjs
import { strict as assert } from 'node:assert';
import { matcher, matcherExcluding } from '../src/index.mjs';

// 1. Separator crossing.
const shallow = matcher('src/*.js');
assert.equal(shallow('src/a.js'), true);
assert.equal(shallow('src/nested/a.js'), false, '* must not cross a separator');
assert.equal(matcher('src/**/*.js')('src/nested/deep/a.js'), true);

// 2. Dotfiles are invisible by default.
assert.equal(matcher('src/**/*.js')('src/.hidden/a.js'), false);
assert.equal(matcher('src/**/*.js', { dot: true })('src/.hidden/a.js'), true);

// 3. The trap: an array is OR-ed, so a "!" entry excludes NOTHING.
const arrayForm = matcher(['src/**/*.js', '!**/*.test.js']);
assert.equal(arrayForm('src/a.js'), true);
assert.equal(arrayForm('src/a.test.js'), true,
  'the negated entry does not subtract - the file still matches the positive pattern');

// The option that actually excludes.
const excluding = matcherExcluding('src/**/*.js', ['**/*.test.js']);
assert.equal(excluding('src/a.js'), true);
assert.equal(excluding('src/a.test.js'), false);

// A lone negated pattern inverts by itself, which is why the array form
// looks like it should work.
const loneNegation = matcher('!**/*.test.js');
assert.equal(loneNegation('src/a.test.js'), false);
assert.equal(loneNegation('src/a.js'), true);

// Braces still expand as expected.
assert.equal(matcher('src/*.{js,ts}')('src/a.ts'), true);

console.log('CONTRACT PASS: picomatch OR-ed the array and excluded only via ignore');

오리진 시더

anonymous