샘플
tinyglobby 0.2.17: match files asynchronously and synchronously using glob and globSync
검증된 샘플 — npm tinyglobby 0.2.17: match files asynchronously and synchronously using glob and globSync. node 22 · linux alpine/x64 · docker에서 contract를 실행해…
sha256:02fc08892554bb3b65639edd583c74ff0e00ff0ec4c0f1cca4729ba98149ceae
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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-08-28 |
케이스
HOW- 목표
- match files asynchronously and synchronously using glob and globSync
- 심벌
-
- glob
- globSync
- 환경
- node 22.23.2
- 생성일
- 2026-08-28T02:16:51Z
컨트랙트
- assert glob asynchronously matches files matching glob patterns
- assert globSync synchronously matches files matching glob patterns
- assert glob and globSync support ignore patterns and negative patterns
- assert glob and globSync support onlyFiles and onlyDirectories filters
- assert glob and globSync support custom cwd and deep options
파일
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
소스
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: match files asynchronously and synchronously using glob and globSync
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/tinyglobby@0.2.17
Demonstrate these symbols/APIs:
- glob
- globSync
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:7b376a2a5a751ed77a756a67e76a0de406000cf8acb6d8d8fdd2594c3baa351c","contract":["assert glob asynchronously matches files matching glob patterns","assert globSync synchronously matches files matching glob patterns","assert glob and globSync support ignore patterns and negative patterns","assert glob and globSync support onlyFiles and onlyDirectories filters","assert glob and globSync support custom cwd and deep options"],"goal":"match files asynchronously and synchronously using glob and globSync","kind":"HOW","packages":["pkg:npm/tinyglobby@0.2.17"],"schemaVersion":1,"symbols":["glob","globSync"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/tinyglobby@0.2.17"],"schemaVersion":1,"subject":"pkg:npm/tinyglobby@0.2.17","symbols":["glob","globSync"],"verifierAdapter":"node-typescript@1"}
import { glob, globSync, convertPathToPattern, escapePath, isDynamicPattern } from 'tinyglobby';
/**
* Asynchronously matches files using glob patterns.
*
* @param {string|string[]} patterns - Glob pattern(s) to match.
* @param {import('tinyglobby').GlobOptions} [options] - Options for matching.
* @returns {Promise<string[]>} Matching file paths.
*/
export async function findFiles(patterns, options = {}) {
return glob(patterns, options);
}
/**
* Synchronously matches files using glob patterns.
*
* @param {string|string[]} patterns - Glob pattern(s) to match.
* @param {import('tinyglobby').GlobOptions} [options] - Options for matching.
* @returns {string[]} Matching file paths.
*/
export function findFilesSync(patterns, options = {}) {
return globSync(patterns, options);
}
export { glob, globSync, convertPathToPattern, escapePath, isDynamicPattern };
{
"name": "sample-tinyglobby",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-tinyglobby",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"tinyglobby": "0.2.17"
}
},
"node_modules/fdir": {
"version": "6.5.0",
"resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz",
"integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==",
"license": "MIT",
"engines": {
"node": ">=12.0.0"
},
"peerDependencies": {
"picomatch": "^3 || ^4"
},
"peerDependenciesMeta": {
"picomatch": {
"optional": true
}
}
},
"node_modules/picomatch": {
"version": "4.0.7",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz",
"integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==",
"license": "MIT",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/jonschlinkert"
}
},
"node_modules/tinyglobby": {
"version": "0.2.17",
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz",
"integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==",
"license": "MIT",
"dependencies": {
"fdir": "^6.5.0",
"picomatch": "^4.0.4"
},
"engines": {
"node": ">=12.0.0"
},
"funding": {
"url": "https://github.com/sponsors/SuperchupuDev"
}
}
}
}
{
"name": "sample-tinyglobby",
"version": "1.0.0",
"description": "Clean-room sample verifying pkg:npm/tinyglobby@0.2.17 functionality",
"type": "module",
"main": "index.js",
"license": "MIT-0",
"dependencies": {
"tinyglobby": "0.2.17"
}
}
{
"schemaVersion": 1,
"goal": "match files asynchronously and synchronously using glob and globSync",
"kind": "HOW",
"packages": [
"pkg:npm/tinyglobby@0.2.17"
],
"symbols": [
"glob",
"globSync"
]
}
import assert from 'node:assert';
import fs from 'node:fs';
import path from 'node:path';
import os from 'node:os';
import { glob, globSync, findFiles, findFilesSync, isDynamicPattern, escapePath } from '../index.js';
// Setup temporary directory structure for offline glob testing
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'tinyglobby-test-'));
try {
fs.writeFileSync(path.join(tmpDir, 'file1.txt'), 'content 1');
fs.writeFileSync(path.join(tmpDir, 'file2.js'), 'console.log("hello");');
fs.writeFileSync(path.join(tmpDir, 'file3.ts'), 'export const x = 1;');
fs.writeFileSync(path.join(tmpDir, '.hidden.txt'), 'hidden');
fs.mkdirSync(path.join(tmpDir, 'sub'), { recursive: true });
fs.writeFileSync(path.join(tmpDir, 'sub', 'nested.js'), 'console.log("nested");');
fs.writeFileSync(path.join(tmpDir, 'sub', 'nested.txt'), 'nested text');
fs.mkdirSync(path.join(tmpDir, 'sub', 'deep'), { recursive: true });
fs.writeFileSync(path.join(tmpDir, 'sub', 'deep', 'deep.js'), 'console.log("deep");');
// 1. Asynchronous matching with glob and findFiles
const asyncJsFiles = (await findFiles('**/*.js', { cwd: tmpDir })).sort();
assert.deepStrictEqual(
asyncJsFiles,
['file2.js', 'sub/deep/deep.js', 'sub/nested.js'],
'assert glob asynchronously matches files matching glob patterns'
);
// 2. Synchronous matching with globSync and findFilesSync
const syncJsFiles = findFilesSync('**/*.js', { cwd: tmpDir }).sort();
assert.deepStrictEqual(
syncJsFiles,
['file2.js', 'sub/deep/deep.js', 'sub/nested.js'],
'assert globSync synchronously matches files matching glob patterns'
);
// 3. Ignore patterns and negative patterns
const ignoredFiles = findFilesSync('**/*.{js,txt}', {
cwd: tmpDir,
ignore: ['**/*.txt', '**/deep/**'],
}).sort();
assert.deepStrictEqual(
ignoredFiles,
['file2.js', 'sub/nested.js'],
'assert glob and globSync support ignore patterns and negative patterns'
);
const negativeGlob = (await glob(['**/*', '!**/*.txt', '!**/deep/**'], { cwd: tmpDir })).sort();
assert.deepStrictEqual(
negativeGlob,
['file2.js', 'file3.ts', 'sub/nested.js'],
'negative patterns filter matching results'
);
// 4. onlyFiles and onlyDirectories filters
const onlyDirs = findFilesSync('*', { cwd: tmpDir, onlyDirectories: true }).sort();
assert.deepStrictEqual(
onlyDirs,
['sub/'],
'assert glob and globSync support onlyFiles and onlyDirectories filters'
);
// 5. Custom cwd and deep option limiting recursion
const shallowFiles = findFilesSync('**/*.js', { cwd: tmpDir, deep: 1 }).sort();
assert.deepStrictEqual(
shallowFiles,
['file2.js', 'sub/nested.js'],
'assert glob and globSync support custom cwd and deep options'
);
// 6. Dot files matching
const dotFiles = findFilesSync('*', { cwd: tmpDir, dot: true }).sort();
assert.ok(
dotFiles.includes('.hidden.txt'),
'dot option allows matching hidden files'
);
// 7. Utility functions
assert.strictEqual(isDynamicPattern('src/**/*.js'), true);
assert.strictEqual(isDynamicPattern('src/plain/file.js'), false);
assert.strictEqual(typeof escapePath('hello/[world]'), 'string');
console.log('All contract assertions passed.');
} finally {
fs.rmSync(tmpDir, { recursive: true, force: true });
}
오리진 시더
익명