CodeSampleX

Beispiel

fs.realpath 1.0.0: monkeypatch

Verifiziertes Beispiel für npm fs.realpath 1.0.0: monkeypatch. Der Vertrag lief auf node 22 · linux debian/x64 · docker und bestand.

sha256:e154c391716c89d66c9c27ae9e7ed83852d84e748e4cc5fe05e735b9b2513bcd

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2…
2026-09-05

Fall

HOW
Ziel
verify fs.realpath.monkeypatch in pkg:npm/fs.realpath@1.0.0
Pakete
Symbole
  • fs.realpath.monkeypatch
Umgebung
node 22.23.2
Erstellt
2026-09-05T17:06:44Z

Contract

  1. assert monkeypatch replaces builtin fs.realpath with polyfill implementation
  2. assert monkeypatch replaces builtin fs.realpathSync with polyfill sync implementation
  3. assert isPatched returns true after applying monkeypatch
  4. assert realpathSync resolves existing directory path while monkeypatched
  5. assert realpath resolves existing directory path asynchronously while monkeypatched
  6. assert realpathSync throws ENOENT when path does not exist while monkeypatched
  7. assert unmonkeypatch restores fs.realpath to native implementation
  8. assert unmonkeypatch restores fs.realpathSync to native implementation
  9. assert isPatched returns false after unmonkeypatching

Dateien

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

Quellartefakt herunterladen (tar.gz)

Quelltext

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 fs.realpath.monkeypatch in pkg:npm/fs.realpath@1.0.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/fs.realpath@1.0.0
Demonstrate these symbols/APIs:
  - fs.realpath.monkeypatch

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:8de9f37d85e1959bc54c163a74e8e0baf5a6dbbec4d04d3ba2be0361a2f50e5c","contract":["assert monkeypatch replaces builtin fs.realpath with polyfill implementation","assert monkeypatch replaces builtin fs.realpathSync with polyfill sync implementation","assert isPatched returns true after applying monkeypatch","assert realpathSync resolves existing directory path while monkeypatched","assert realpath resolves existing directory path asynchronously while monkeypatched","assert realpathSync throws ENOENT when path does not exist while monkeypatched","assert unmonkeypatch restores fs.realpath to native implementation","assert unmonkeypatch restores fs.realpathSync to native implementation","assert isPatched returns false after unmonkeypatching"],"goal":"verify fs.realpath.monkeypatch in pkg:npm/fs.realpath@1.0.0","kind":"HOW","packages":["pkg:npm/fs.realpath@1.0.0"],"schemaVersion":1,"symbols":["fs.realpath.monkeypatch"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/fs.realpath@1.0.0"],"schemaVersion":1,"subject":"pkg:npm/fs.realpath@1.0.0","symbols":["fs.realpath.monkeypatch"],"verifierAdapter":"node-typescript@1"}
index.js
const fs = require('fs');
const rp = require('fs.realpath');

function enableMonkeypatch() {
  rp.monkeypatch();
}

function disableMonkeypatch() {
  rp.unmonkeypatch();
}

function isPatched() {
  return fs.realpath === rp && fs.realpathSync === rp.sync;
}

function resolveRealPathSync(targetPath) {
  return fs.realpathSync(targetPath);
}

function resolveRealPathAsync(targetPath) {
  return new Promise((resolve, reject) => {
    fs.realpath(targetPath, (err, resolved) => {
      if (err) {
        reject(err);
      } else {
        resolve(resolved);
      }
    });
  });
}

module.exports = {
  enableMonkeypatch,
  disableMonkeypatch,
  isPatched,
  resolveRealPathSync,
  resolveRealPathAsync,
  rp,
};
package-lock.json
{
  "name": "sample-fs-realpath",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-fs-realpath",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "fs.realpath": "1.0.0"
      }
    },
    "node_modules/fs.realpath": {
      "version": "1.0.0",
      "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
      "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==",
      "license": "ISC"
    }
  }
}
package.json
{
  "name": "sample-fs-realpath",
  "version": "1.0.0",
  "description": "Clean-room sample verifying fs.realpath.monkeypatch in fs.realpath",
  "main": "index.js",
  "license": "MIT-0",
  "dependencies": {
    "fs.realpath": "1.0.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify fs.realpath.monkeypatch in pkg:npm/fs.realpath@1.0.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/fs.realpath@1.0.0"
  ],
  "symbols": [
    "fs.realpath.monkeypatch"
  ]
}
test/contract.mjs
import assert from 'node:assert';
import fs from 'node:fs';
import rp from 'fs.realpath';
import {
  enableMonkeypatch,
  disableMonkeypatch,
  isPatched,
  resolveRealPathSync,
  resolveRealPathAsync,
} from '../index.js';

const origRealpath = fs.realpath;
const origRealpathSync = fs.realpathSync;

// 1. Initial state: unpatched
assert.strictEqual(fs.realpath, origRealpath, 'Initial fs.realpath must match native implementation');
assert.strictEqual(fs.realpathSync, origRealpathSync, 'Initial fs.realpathSync must match native implementation');
assert.strictEqual(isPatched(), false, 'isPatched must return false before monkeypatch');

// 2. Apply monkeypatch
enableMonkeypatch();
assert.strictEqual(fs.realpath, rp, 'assert monkeypatch replaces builtin fs.realpath with polyfill implementation');
assert.strictEqual(fs.realpathSync, rp.sync, 'assert monkeypatch replaces builtin fs.realpathSync with polyfill sync implementation');
assert.strictEqual(isPatched(), true, 'assert isPatched returns true after applying monkeypatch');

// 3. Resolve existing directory path synchronously while patched
const resolvedSync = resolveRealPathSync('.');
assert.strictEqual(typeof resolvedSync, 'string', 'assert resolveRealPathSync returns string');
assert.ok(resolvedSync.length > 0, 'assert realpathSync resolves existing directory path while monkeypatched');

// 4. Resolve existing directory path asynchronously while patched
const resolvedAsync = await resolveRealPathAsync('.');
assert.strictEqual(resolvedAsync, resolvedSync, 'assert realpath resolves existing directory path asynchronously while monkeypatched');

// 5. Error handling for nonexistent path while patched
assert.throws(
  () => {
    resolveRealPathSync('./nonexistent_path_contract_check_404');
  },
  /ENOENT/,
  'assert realpathSync throws ENOENT when path does not exist while monkeypatched'
);

// 6. Restore original and verify unmonkeypatching
disableMonkeypatch();
assert.strictEqual(fs.realpath, origRealpath, 'assert unmonkeypatch restores fs.realpath to native implementation');
assert.strictEqual(fs.realpathSync, origRealpathSync, 'assert unmonkeypatch restores fs.realpathSync to native implementation');
assert.strictEqual(isPatched(), false, 'assert isPatched returns false after unmonkeypatching');

console.log('All fs.realpath.monkeypatch contract assertions passed.');

Ursprungs-Seeder

anonym