CodeSampleX

サンプル

fast-glob 3.3.3: sync

検証済みサンプル — npm fast-glob 3.3.3: sync. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: fg.sync finds files matching single and multiple glob…

sha256:e02c909e5f859ad44f017abe565c3ac82e90633f95ba5a20dc254946ad024bcb

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 MIT-0

実行証拠

宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。

証拠の基準
署名済みコントラクト合格
検証レシート
1
ビルドした署名鍵
1
宣言された環境 linux 24 · ubuntu · glibc 2.39 x64 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-21

ケース

HOW
ゴール
verify fast-glob.sync in pkg:npm/fast-glob@3.3.3
パッケージ
シンボル
  • fast-glob.sync
作成日
2026-08-21T07:40:39Z

コントラクト

  1. fg.sync finds files matching single and multiple glob patterns synchronously
  2. fg.sync with cwd option scopes pattern matching to the specified directory
  3. fg.sync with absolute option returns absolute filesystem paths for all matched entries
  4. fg.sync with ignore option filters matching files and directories
  5. fg.sync with onlyDirectories and markDirectories returns directory paths with trailing slashes
  6. fg.sync with caseSensitiveMatch false matches files regardless of filename casing

ファイル

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • test/contract.mjs

ソースアーティファクトをダウンロード (tar.gz)

ソース

PROMPT.md
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: verify fast-glob.sync in pkg:npm/fast-glob@3.3.3
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/fast-glob@3.3.3
Demonstrate these symbols/APIs:
  - fast-glob.sync

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.
csx.json
{"case":{"caseId":"case:sha256:5f99fdc08285e70d6736f6af2a902a9fb7d1475ac9ef1abca4332ce7a047484a","contract":["fg.sync finds files matching single and multiple glob patterns synchronously","fg.sync with cwd option scopes pattern matching to the specified directory","fg.sync with absolute option returns absolute filesystem paths for all matched entries","fg.sync with ignore option filters matching files and directories","fg.sync with onlyDirectories and markDirectories returns directory paths with trailing slashes","fg.sync with caseSensitiveMatch false matches files regardless of filename casing"],"goal":"verify fast-glob.sync in pkg:npm/fast-glob@3.3.3","kind":"HOW","packages":["pkg:npm/fast-glob@3.3.3"],"schemaVersion":1,"symbols":["fast-glob.sync"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/fast-glob@3.3.3"],"schemaVersion":1,"subject":"pkg:npm/fast-glob@3.3.3","symbols":["fast-glob.sync"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-fast-glob-sync",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-fast-glob-sync",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "fast-glob": "3.3.3"
      }
    },
    "node_modules/@nodelib/fs.scandir": {
      "version": "2.1.5",
      "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
      "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==",
      "license": "MIT",
      "dependencies": {
        "@nodelib/fs.stat": "2.0.5",
        "run-parallel": "^1.1.9"
      },
      "engines": {
        "node": ">= 8"
      }
    },
    "node_modules/@nodelib/fs.stat": {
      "version": "2.0.5",
      "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz",
      "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==",
      "license": "MIT",
      "engines": {
        "node": ">= 8"
      }
    },
    "node_modules/@nodelib/fs.walk": {
      "version": "1.2.8",
      "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz",
      "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==",
      "license": "MIT",
      "dependencies": {
        "@nodelib/fs.scandir": "2.1.5",
        "fastq": "^1.6.0"
      },
      "engines": {
        "node": ">= 8"
      }
    },
    "node_modules/braces": {
      "version": "3.0.3",
      "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz",
      "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==",
      "license": "MIT",
      "dependencies": {
        "fill-range": "^7.1.1"
      },
      "engines": {
        "node": ">=8"
      }
    },
    "node_modules/fast-glob": {
      "version": "3.3.3",
      "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz",
      "integrity": "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==",
      "license": "MIT",
      "dependencies": {
        "@nodelib/fs.stat": "^2.0.2",
        "@nodelib/fs.walk": "^1.2.3",
        "glob-parent": "^5.1.2",
        "merge2": "^1.3.0",
        "micromatch": "^4.0.8"
      },
      "engines": {
        "node": ">=8.6.0"
      }
    },
    "node_modules/fastq": {
      "version": "1.20.1",
      "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.20.1.tgz",
      "integrity": "sha512-GGToxJ/w1x32s/D2EKND7kTil4n8OVk/9mycTc4VDza13lOvpUZTGX3mFSCtV9ksdGBVzvsyAVLM6mHFThxXxw==",
      "license": "ISC",
      "dependencies": {
        "reusify": "^1.0.4"
      }
    },
    "node_modules/fill-range": {
      "version": "7.1.1",
      "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
      "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
      "license": "MIT",
      "dependencies": {
        "to-regex-range": "^5.0.1"
      },
      "engines": {
        "node": ">=8"
      }
    },
    "node_modules/glob-parent": {
      "version": "5.1.2",
      "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
      "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
      "license": "ISC",
      "dependencies": {
        "is-glob": "^4.0.1"
      },
      "engines": {
        "node": ">= 6"
      }
    },
    "node_modules/is-extglob": {
      "version": "2.1.1",
      "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
      "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==",
      "license": "MIT",
      "engines": {
        "node": ">=0.10.0"
      }
    },
    "node_modules/is-glob": {
      "version": "4.0.3",
      "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz",
      "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
      "license": "MIT",
      "dependencies": {
        "is-extglob": "^2.1.1"
      },
      "engines": {
        "node": ">=0.10.0"
      }
    },
    "node_modules/is-number": {
      "version": "7.0.0",
      "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
      "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
      "license": "MIT",
      "engines": {
        "node": ">=0.12.0"
      }
    },
    "node_modules/merge2": {
      "version": "1.4.1",
      "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz",
      "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==",
      "license": "MIT",
      "engines": {
        "node": ">= 8"
      }
    },
    "node_modules/micromatch": {
      "version": "4.0.8",
      "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
      "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
      "license": "MIT",
      "dependencies": {
        "braces": "^3.0.3",
        "picomatch": "^2.3.1"
      },
      "engines": {
        "node": ">=8.6"
      }
    },
    "node_modules/picomatch": {
      "version": "2.3.2",
      "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz",
      "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==",
      "license": "MIT",
      "engines": {
        "node": ">=8.6"
      },
      "funding": {
        "url": "https://github.com/sponsors/jonschlinkert"
      }
    },
    "node_modules/queue-microtask": {
      "version": "1.2.3",
      "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz",
      "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==",
      "funding": [
        {
          "type": "github",
          "url": "https://github.com/sponsors/feross"
        },
        {
          "type": "patreon",
          "url": "https://www.patreon.com/feross"
        },
        {
          "type": "consulting",
          "url": "https://feross.org/support"
        }
      ],
      "license": "MIT"
    },
    "node_modules/reusify": {
      "version": "1.1.0",
      "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.1.0.tgz",
      "integrity": "sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==",
      "license": "MIT",
      "engines": {
        "iojs": ">=1.0.0",
        "node": ">=0.10.0"
      }
    },
    "node_modules/run-parallel": {
      "version": "1.2.0",
      "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz",
      "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==",
      "funding": [
        {
          "type": "github",
          "url": "https://github.com/sponsors/feross"
        },
        {
          "type": "patreon",
          "url": "https://www.patreon.com/feross"
        },
        {
          "type": "consulting",
          "url": "https://feross.org/support"
        }
      ],
      "license": "MIT",
      "dependencies": {
        "queue-microtask": "^1.2.2"
      }
    },
    "node_modules/to-regex-range": {
      "version": "5.0.1",
      "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
      "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
      "license": "MIT",
      "dependencies": {
        "is-number": "^7.0.0"
      },
      "engines": {
        "node": ">=8.0"
      }
    }
  }
}
package.json
{
  "name": "sample-fast-glob-sync",
  "version": "1.0.0",
  "private": true,
  "description": "verify fast-glob.sync in pkg:npm/fast-glob@3.3.3",
  "main": "src/index.js",
  "license": "MIT-0",
  "dependencies": {
    "fast-glob": "3.3.3"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify fast-glob.sync in pkg:npm/fast-glob@3.3.3",
  "kind": "HOW",
  "packages": [
    "pkg:npm/fast-glob@3.3.3"
  ],
  "symbols": [
    "fast-glob.sync"
  ]
}
src/index.js
const fg = require('fast-glob');

/**
 * Finds file paths matching given glob patterns synchronously.
 *
 * @param {string|string[]} patterns - Glob pattern or patterns.
 * @param {object} [options] - Fast-glob options.
 * @returns {string[]} Matched file paths.
 */
function findFiles(patterns, options = {}) {
  return fg.sync(patterns, options);
}

/**
 * Finds directory paths matching given glob patterns synchronously.
 *
 * @param {string|string[]} patterns - Glob pattern or patterns.
 * @param {object} [options] - Fast-glob options.
 * @returns {string[]} Matched directory paths with trailing slash.
 */
function findDirectories(patterns, options = {}) {
  return fg.sync(patterns, {
    ...options,
    onlyDirectories: true,
    markDirectories: true
  });
}

module.exports = {
  sync: fg.sync,
  findFiles,
  findDirectories
};
test/contract.mjs
import assert from 'node:assert/strict';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const { sync, findFiles, findDirectories } = require('../src/index.js');
const fastGlob = require('fast-glob');

// Ensure sync export matches fast-glob.sync
assert.strictEqual(sync, fastGlob.sync, 'sync must export fast-glob.sync');

const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'fg-contract-'));

try {
  fs.mkdirSync(path.join(tempDir, 'src', 'data'), { recursive: true });
  fs.mkdirSync(path.join(tempDir, 'src', 'assets'), { recursive: true });
  fs.mkdirSync(path.join(tempDir, 'docs'), { recursive: true });

  fs.writeFileSync(path.join(tempDir, 'src', 'index.ts'), 'export {}');
  fs.writeFileSync(path.join(tempDir, 'src', 'utils.js'), 'module.exports = {}');
  fs.writeFileSync(path.join(tempDir, 'src', 'data', 'config.json'), '{}');
  fs.writeFileSync(path.join(tempDir, 'src', 'data', 'secret.log'), 'secret');
  fs.writeFileSync(path.join(tempDir, 'src', 'assets', 'IMAGE.PNG'), 'png');
  fs.writeFileSync(path.join(tempDir, 'docs', 'guide.md'), '# Guide');

  // 1. fg.sync finds files matching single and multiple glob patterns synchronously
  const single = sync('**/*.ts', { cwd: tempDir });
  assert.deepStrictEqual(single, ['src/index.ts']);

  const multiple = findFiles(['**/*.ts', '**/*.js'], { cwd: tempDir }).sort();
  assert.deepStrictEqual(multiple, ['src/index.ts', 'src/utils.js']);

  // 2. fg.sync with cwd option scopes pattern matching to the specified directory
  const scoped = sync('**/*', { cwd: path.join(tempDir, 'src'), onlyFiles: true }).sort();
  assert.deepStrictEqual(scoped, [
    'assets/IMAGE.PNG',
    'data/config.json',
    'data/secret.log',
    'index.ts',
    'utils.js'
  ]);

  // 3. fg.sync with absolute option returns absolute filesystem paths for all matched entries
  const abs = sync('**/*.ts', { cwd: tempDir, absolute: true });
  assert.strictEqual(abs.length, 1);
  assert.strictEqual(abs[0], path.join(tempDir, 'src', 'index.ts'));

  // 4. fg.sync with ignore option filters matching files and directories
  const filtered = sync('**/*', {
    cwd: tempDir,
    ignore: ['**/*.log', 'docs/**'],
    onlyFiles: true
  }).sort();
  assert.deepStrictEqual(filtered, [
    'src/assets/IMAGE.PNG',
    'src/data/config.json',
    'src/index.ts',
    'src/utils.js'
  ]);

  // 5. fg.sync with onlyDirectories and markDirectories returns directory paths with trailing slashes
  const dirs = findDirectories('**/*', { cwd: tempDir }).sort();
  assert.deepStrictEqual(dirs, [
    'docs/',
    'src/',
    'src/assets/',
    'src/data/'
  ]);

  // 6. fg.sync with caseSensitiveMatch false matches files regardless of filename casing
  const caseSensitive = sync('**/*.png', { cwd: tempDir, caseSensitiveMatch: true });
  assert.strictEqual(caseSensitive.length, 0);

  const caseInsensitive = sync('**/*.png', { cwd: tempDir, caseSensitiveMatch: false });
  assert.deepStrictEqual(caseInsensitive, ['src/assets/IMAGE.PNG']);

  console.log('Contract assertions passed.');
} finally {
  fs.rmSync(tempDir, { recursive: true, force: true });
}

オリジンシーダー

匿名