샘플
ignore 5.3.2: Filter and test file paths against gitignore rules using ignore
검증된 샘플 — npm ignore 5.3.2: Filter and test file paths against gitignore rules using ignore. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다.
sha256:96b17c776914936d62bb4b37c44d616ea0cd78e138f2a088182dba0f874e4584
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-20 |
케이스
HOW- 목표
- Filter and test file paths against gitignore rules using ignore
- 패키지
- 심벌
-
- Ignore#add
- Ignore#createFilter
- Ignore#filter
- Ignore#ignores
- Ignore#test
- ignore
- 환경
- node 22.23.2
- 생성일
- 2026-08-20T22:53:31Z
컨트랙트
- assert ignore() creates and returns an Ignore instance
- assert Ignore#add registers gitignore rules from strings and arrays and supports method chaining
- assert Ignore#ignores returns true for ignored paths and false for non-ignored or negated paths
- assert Ignore#filter filters an array of file paths and returns only unignored paths
- assert Ignore#createFilter returns a predicate function suitable for Array#filter matching Ignore#filter behavior
- assert Ignore#test returns an object with { ignored, unignored } boolean flags reflecting matching gitignore rules
파일
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.cjs
소스
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: Filter and test file paths against gitignore rules using ignore
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/ignore@5.3.2
Demonstrate these symbols/APIs:
- Ignore#add
- Ignore#createFilter
- Ignore#filter
- Ignore#ignores
- Ignore#test
- ignore
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- runtime: node@22.23.2
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:52be1d3058bf8f0882c023f67e62b6427fa943fdfbb682c9c3d2bd3ea39347ce","constraints":{"executionContext":"node"},"contract":["assert ignore() creates and returns an Ignore instance","assert Ignore#add registers gitignore rules from strings and arrays and supports method chaining","assert Ignore#ignores returns true for ignored paths and false for non-ignored or negated paths","assert Ignore#filter filters an array of file paths and returns only unignored paths","assert Ignore#createFilter returns a predicate function suitable for Array#filter matching Ignore#filter behavior","assert Ignore#test returns an object with { ignored, unignored } boolean flags reflecting matching gitignore rules"],"goal":"Filter and test file paths against gitignore rules using ignore","kind":"HOW","packages":["pkg:npm/ignore@5.3.2"],"schemaVersion":1,"symbols":["Ignore#add","Ignore#createFilter","Ignore#filter","Ignore#ignores","Ignore#test","ignore"]},"contractCommand":["node","test/contract.cjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/ignore@5.3.2"],"schemaVersion":1,"subject":"pkg:npm/ignore@5.3.2","symbols":["Ignore#add","Ignore#createFilter","Ignore#filter","Ignore#ignores","Ignore#test","ignore"],"verifierAdapter":"node-typescript@1"}
'use strict';
const ignore = require('ignore');
/**
* Creates an Ignore instance initialized with the specified gitignore patterns.
*
* @param {string|string[]} patterns - Glob patterns or list of patterns.
* @param {object} [options] - Options passed to the ignore factory.
* @returns {import('ignore').Ignore} An Ignore instance with registered rules.
*/
function createPathFilter(patterns, options) {
const ig = ignore(options);
if (patterns) {
ig.add(patterns);
}
return ig;
}
/**
* Filters an array of relative file paths, returning only those not ignored.
*
* @param {string[]} paths - Candidate file paths.
* @param {string|string[]} patterns - Gitignore patterns to match against.
* @param {object} [options] - Options passed to the ignore factory.
* @returns {string[]} Array of unignored file paths.
*/
function filterPaths(paths, patterns, options) {
const ig = createPathFilter(patterns, options);
return ig.filter(paths);
}
/**
* Checks whether a single relative file path is ignored.
*
* @param {string} pathname - Relative file path to test.
* @param {string|string[]} patterns - Gitignore patterns.
* @param {object} [options] - Options passed to the ignore factory.
* @returns {boolean} True if the path matches ignore rules.
*/
function isPathIgnored(pathname, patterns, options) {
const ig = createPathFilter(patterns, options);
return ig.ignores(pathname);
}
/**
* Tests a path against gitignore rules and returns match details.
*
* @param {string} pathname - Relative file path to test.
* @param {string|string[]} patterns - Gitignore patterns.
* @param {object} [options] - Options passed to the ignore factory.
* @returns {{ ignored: boolean, unignored: boolean }} Result with ignored/unignored status.
*/
function testPath(pathname, patterns, options) {
const ig = createPathFilter(patterns, options);
return ig.test(pathname);
}
module.exports = {
createPathFilter,
filterPaths,
isPathIgnored,
testPath,
ignore,
};
{
"name": "ignore-path-filter",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "ignore-path-filter",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"ignore": "5.3.2"
}
},
"node_modules/ignore": {
"version": "5.3.2",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz",
"integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==",
"license": "MIT",
"engines": {
"node": ">= 4"
}
}
}
}
{
"name": "ignore-path-filter",
"version": "1.0.0",
"private": true,
"description": "Filter and test file paths against gitignore rules using ignore",
"main": "index.js",
"scripts": {
"test": "node test/contract.cjs"
},
"dependencies": {
"ignore": "5.3.2"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "Filter and test file paths against gitignore rules using ignore",
"kind": "HOW",
"packages": [
"pkg:npm/ignore@5.3.2"
],
"symbols": [
"Ignore#add",
"Ignore#createFilter",
"Ignore#filter",
"Ignore#ignores",
"Ignore#test",
"ignore"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"runtime": "node@22.23.2"
}
}
'use strict';
const assert = require('node:assert');
const ignore = require('ignore');
const {
createPathFilter,
filterPaths,
isPathIgnored,
testPath,
} = require('../index.js');
// 1. Factory function: ignore()
const ig = ignore();
assert(ig && typeof ig.add === 'function', 'ignore() should return an Ignore instance');
// 2. Ignore#add method and method chaining
const chainResult = ig.add('*.tmp').add(['build/*', '!build/output.json', 'temp/']);
assert.strictEqual(chainResult, ig, 'Ignore#add should return the instance for method chaining');
// 3. Ignore#ignores method
assert.strictEqual(ig.ignores('cache.tmp'), true, 'Should ignore *.tmp files');
assert.strictEqual(ig.ignores('src/app.js'), false, 'Should not ignore unlisted files');
assert.strictEqual(ig.ignores('build/debug.log'), true, 'Should ignore files inside build/*');
assert.strictEqual(ig.ignores('build/output.json'), false, 'Should not ignore negated !build/output.json');
assert.strictEqual(ig.ignores('temp/nested/file.txt'), true, 'Should ignore paths under temp/ directory');
// 4. Ignore#filter method
const fileList = [
'src/index.js',
'cache.tmp',
'build/debug.log',
'build/output.json',
'temp/data.csv',
'docs/readme.md',
];
const filteredFiles = ig.filter(fileList);
assert.deepStrictEqual(
filteredFiles,
['src/index.js', 'build/output.json', 'docs/readme.md'],
'Ignore#filter should only keep unignored paths'
);
// 5. Ignore#createFilter method
const filterPredicate = ig.createFilter();
assert.strictEqual(typeof filterPredicate, 'function', 'Ignore#createFilter should return a function');
const predicateFiltered = fileList.filter(filterPredicate);
assert.deepStrictEqual(
predicateFiltered,
['src/index.js', 'build/output.json', 'docs/readme.md'],
'Ignore#createFilter predicate should produce identical results to Ignore#filter'
);
// 6. Ignore#test method
const testIgnored = ig.test('cache.tmp');
assert.deepStrictEqual(
testIgnored,
{ ignored: true, unignored: false },
'Ignore#test should return { ignored: true, unignored: false } for ignored paths'
);
const testNegated = ig.test('build/output.json');
assert.deepStrictEqual(
testNegated,
{ ignored: false, unignored: true },
'Ignore#test should return { ignored: false, unignored: true } for negated unignored paths'
);
const testUnmatched = ig.test('src/index.js');
assert.deepStrictEqual(
testUnmatched,
{ ignored: false, unignored: false },
'Ignore#test should return { ignored: false, unignored: false } for unreferenced paths'
);
// 7. Verify helper module functions
const helperIg = createPathFilter(['*.bak', 'dist/*']);
assert.strictEqual(isPathIgnored('file.bak', ['*.bak']), true);
assert.strictEqual(isPathIgnored('file.txt', ['*.bak']), false);
const helperFiltered = filterPaths(['a.txt', 'b.bak', 'c.md'], ['*.bak']);
assert.deepStrictEqual(helperFiltered, ['a.txt', 'c.md']);
const helperTest = testPath('b.bak', ['*.bak']);
assert.strictEqual(helperTest.ignored, true);
console.log('All contract assertions passed successfully.');
오리진 시더
익명