Exemple
@istanbuljs/load-nyc-config 1.1.0: load NYC configuration asynchronously using @istanbuljs/load-nyc-config
Échantillon vérifié pour npm @istanbuljs/load-nyc-config 1.1.0: load NYC configuration asynchronously using @istanbuljs/load-nyc-config. Le contrat s'est…
sha256:f857ba4f05eebd6d89091a1cc48a3ad72904244c7ea2a67bcba1442c68b9b0d1
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
linux 24 · ubuntu · glibc 2.39 x64 npm
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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-27 |
Cas
HOW- Objectif
- load NYC configuration asynchronously using @istanbuljs/load-nyc-config
- Symboles
-
- loadNycConfig
- Créé
- 2026-08-27T21:28:26Z
Contrat
- assert loadNycConfig asynchronously loads configuration from package.json with camelCase normalization and resolved cwd
- assert loadNycConfig asynchronously loads configuration from .nycrc.json with precedence over package.json
- assert loadNycConfig asynchronously loads specific configuration file specified via nycrcPath option
- assert loadNycConfig rejects when specified nycrcPath configuration file does not exist
- assert loadNycConfig normalizes singular string values to arrays for array fields
- assert loadNycConfig merges extended configurations where extended file properties apply over extending file
- assert loadNycConfig rejects when circular extended configurations are detected
- assert isLoading returns boolean false when configuration loading is idle
Fichiers
- PROMPT.md
- csx.json
- index.mjs
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Code source
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: load NYC configuration asynchronously using @istanbuljs/load-nyc-config
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40istanbuljs/load-nyc-config@1.1.0
Demonstrate these symbols/APIs:
- loadNycConfig
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:11216b67914ce811f50c7f2c6bcf5e4b9d422084d768023ed7e896176d9f7c41","contract":["assert loadNycConfig asynchronously loads configuration from package.json with camelCase normalization and resolved cwd","assert loadNycConfig asynchronously loads configuration from .nycrc.json with precedence over package.json","assert loadNycConfig asynchronously loads specific configuration file specified via nycrcPath option","assert loadNycConfig rejects when specified nycrcPath configuration file does not exist","assert loadNycConfig normalizes singular string values to arrays for array fields","assert loadNycConfig merges extended configurations where extended file properties apply over extending file","assert loadNycConfig rejects when circular extended configurations are detected","assert isLoading returns boolean false when configuration loading is idle"],"goal":"load NYC configuration asynchronously using @istanbuljs/load-nyc-config","kind":"HOW","packages":["pkg:npm/%40istanbuljs/load-nyc-config@1.1.0"],"schemaVersion":1,"symbols":["loadNycConfig"]},"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/%40istanbuljs/load-nyc-config@1.1.0"],"schemaVersion":1,"subject":"pkg:npm/%40istanbuljs/load-nyc-config@1.1.0","symbols":["loadNycConfig"],"verifierAdapter":"node-typescript@1"}
import { loadNycConfig, isLoading } from '@istanbuljs/load-nyc-config';
/**
* Loads NYC configuration asynchronously for the given directory or options.
*
* @param {object} [options]
* @param {string} [options.cwd]
* @param {string|string[]} [options.nycrcPath]
* @returns {Promise<Record<string, any>>}
*/
export async function loadConfig(options) {
return loadNycConfig(options);
}
/**
* Checks if configuration loading is currently in progress.
*
* @returns {boolean}
*/
export function isCurrentlyLoading() {
return isLoading();
}
export { loadNycConfig, isLoading };
export default loadNycConfig;
{
"name": "sample-load-nyc-config",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-load-nyc-config",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"@istanbuljs/load-nyc-config": "1.1.0"
}
},
"node_modules/@istanbuljs/load-nyc-config": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz",
"integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==",
"license": "ISC",
"dependencies": {
"camelcase": "^5.3.1",
"find-up": "^4.1.0",
"get-package-type": "^0.1.0",
"js-yaml": "^3.13.1",
"resolve-from": "^5.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/argparse": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
"license": "MIT",
"dependencies": {
"sprintf-js": "~1.0.2"
}
},
"node_modules/camelcase": {
"version": "5.3.1",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz",
"integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==",
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/esprima": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
"license": "BSD-2-Clause",
"bin": {
"esparse": "bin/esparse.js",
"esvalidate": "bin/esvalidate.js"
},
"engines": {
"node": ">=4"
}
},
"node_modules/find-up": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz",
"integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==",
"license": "MIT",
"dependencies": {
"locate-path": "^5.0.0",
"path-exists": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/get-package-type": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz",
"integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==",
"license": "MIT",
"engines": {
"node": ">=8.0.0"
}
},
"node_modules/js-yaml": {
"version": "3.15.2",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.15.2.tgz",
"integrity": "sha512-6EuL879VkRA+1Cz578mKMiKvjPNEuk6+r1JaFzoSWejZmtf7xWbIyw1e3KkxlkzTIt9Taw6JBhEppG7utc1P+w==",
"license": "MIT",
"dependencies": {
"argparse": "^1.0.7",
"esprima": "^4.0.0"
},
"bin": {
"js-yaml": "bin/js-yaml.js"
}
},
"node_modules/locate-path": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
"integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==",
"license": "MIT",
"dependencies": {
"p-locate": "^4.1.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/p-limit": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz",
"integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",
"license": "MIT",
"dependencies": {
"p-try": "^2.0.0"
},
"engines": {
"node": ">=6"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/p-locate": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz",
"integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==",
"license": "MIT",
"dependencies": {
"p-limit": "^2.2.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/p-try": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz",
"integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==",
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/path-exists": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
"integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/resolve-from": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz",
"integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/sprintf-js": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
"integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==",
"license": "BSD-3-Clause"
}
}
}
{
"name": "sample-load-nyc-config",
"version": "1.0.0",
"description": "Clean-room sample demonstrating @istanbuljs/load-nyc-config",
"main": "index.mjs",
"type": "module",
"license": "MIT-0",
"dependencies": {
"@istanbuljs/load-nyc-config": "1.1.0"
}
}
{
"schemaVersion": 1,
"goal": "load NYC configuration asynchronously using @istanbuljs/load-nyc-config",
"kind": "HOW",
"packages": [
"pkg:npm/%40istanbuljs/load-nyc-config@1.1.0"
],
"symbols": [
"loadNycConfig"
]
}
import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import os from 'node:os';
import { loadNycConfig, isLoading, loadConfig, isCurrentlyLoading } from '../index.mjs';
const tmpBase = fs.mkdtempSync(path.join(os.tmpdir(), 'load-nyc-config-contract-'));
try {
// 1. assert loadNycConfig asynchronously loads configuration from package.json with camelCase normalization and resolved cwd
{
const dir = path.join(tmpBase, 'pkg-json-test');
fs.mkdirSync(dir, { recursive: true });
fs.writeFileSync(
path.join(dir, 'package.json'),
JSON.stringify({
name: 'test-pkg',
nyc: {
'check-coverage': true,
lines: 95,
'per-file': false
}
}),
'utf8'
);
const config = await loadConfig({ cwd: dir });
assert.strictEqual(config.cwd, dir);
assert.strictEqual(config.checkCoverage, true);
assert.strictEqual(config.lines, 95);
assert.strictEqual(config.perFile, false);
}
// 2. assert loadNycConfig asynchronously loads configuration from .nycrc.json with precedence over package.json
{
const dir = path.join(tmpBase, 'nycrc-json-test');
fs.mkdirSync(dir, { recursive: true });
fs.writeFileSync(
path.join(dir, 'package.json'),
JSON.stringify({
name: 'test-pkg',
nyc: {
lines: 80,
all: false
}
}),
'utf8'
);
fs.writeFileSync(
path.join(dir, '.nycrc.json'),
JSON.stringify({
lines: 100,
all: true,
'report-dir': './coverage-output'
}),
'utf8'
);
const config = await loadNycConfig({ cwd: dir });
assert.strictEqual(config.cwd, dir);
assert.strictEqual(config.lines, 100);
assert.strictEqual(config.all, true);
assert.strictEqual(config.reportDir, './coverage-output');
}
// 3. assert loadNycConfig asynchronously loads specific configuration file specified via nycrcPath option
{
const dir = path.join(tmpBase, 'custom-path-test');
fs.mkdirSync(dir, { recursive: true });
const customConfigPath = path.join(dir, 'custom-nyc.json');
fs.writeFileSync(
customConfigPath,
JSON.stringify({
'temp-dir': '.custom-nyc_output',
instrument: false
}),
'utf8'
);
const config = await loadNycConfig({ cwd: dir, nycrcPath: customConfigPath });
assert.strictEqual(config.tempDir, '.custom-nyc_output');
assert.strictEqual(config.instrument, false);
}
// 4. assert loadNycConfig rejects when specified nycrcPath configuration file does not exist
{
const dir = path.join(tmpBase, 'missing-path-test');
fs.mkdirSync(dir, { recursive: true });
const nonExistentPath = path.join(dir, 'does-not-exist.json');
await assert.rejects(
async () => {
await loadNycConfig({ cwd: dir, nycrcPath: nonExistentPath });
},
{
name: 'Error',
message: `Requested configuration file ${nonExistentPath} not found`
}
);
}
// 5. assert loadNycConfig normalizes singular string values to arrays for array fields
{
const dir = path.join(tmpBase, 'array-norm-test');
fs.mkdirSync(dir, { recursive: true });
fs.writeFileSync(
path.join(dir, '.nycrc'),
JSON.stringify({
require: 'ts-node/register',
extension: '.ts',
exclude: 'tests/**',
include: 'src/**'
}),
'utf8'
);
const config = await loadNycConfig({ cwd: dir });
assert.deepStrictEqual(config.require, ['ts-node/register']);
assert.deepStrictEqual(config.extension, ['.ts']);
assert.deepStrictEqual(config.exclude, ['tests/**']);
assert.deepStrictEqual(config.include, ['src/**']);
}
// 6. assert loadNycConfig merges extended configurations where extended file properties apply over extending file
{
const dir = path.join(tmpBase, 'extends-test');
fs.mkdirSync(dir, { recursive: true });
const baseConfigPath = path.join(dir, 'base-nyc.json');
fs.writeFileSync(
baseConfigPath,
JSON.stringify({
all: true,
branches: 85,
lines: 85
}),
'utf8'
);
fs.writeFileSync(
path.join(dir, '.nycrc.json'),
JSON.stringify({
extends: './base-nyc.json',
branches: 50,
statements: 90
}),
'utf8'
);
const config = await loadNycConfig({ cwd: dir });
assert.strictEqual(config.all, true);
assert.strictEqual(config.branches, 85);
assert.strictEqual(config.lines, 85);
assert.strictEqual(config.statements, 90);
}
// 7. assert loadNycConfig rejects when circular extended configurations are detected
{
const dir = path.join(tmpBase, 'circular-extends-test');
fs.mkdirSync(dir, { recursive: true });
const configA = path.join(dir, 'config-a.json');
const configB = path.join(dir, 'config-b.json');
fs.writeFileSync(
configA,
JSON.stringify({
extends: './config-b.json'
}),
'utf8'
);
fs.writeFileSync(
configB,
JSON.stringify({
extends: './config-a.json'
}),
'utf8'
);
await assert.rejects(
async () => {
await loadNycConfig({ cwd: dir, nycrcPath: configA });
},
(err) => {
assert.strictEqual(err.name, 'Error');
assert.ok(err.message.includes('Circular extended configurations'));
return true;
}
);
}
// 8. assert isLoading returns boolean false when configuration loading is idle
{
assert.strictEqual(isLoading(), false);
assert.strictEqual(isCurrentlyLoading(), false);
}
console.log('All contracts passed successfully.');
} finally {
fs.rmSync(tmpBase, { recursive: true, force: true });
}
Seeder d'origine
anonyme