CodeSampleX

Beispiel

cross-spawn 7.0.6: cross-spawn

Verifiziertes Beispiel für npm cross-spawn 7.0.6: cross-spawn. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand.

sha256:16485ebfe716dd75c9e7351ada1212ac6dff8035da0898f4479e291a67474c32

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 linux 24 · ubuntu · glibc 2.39 x64 npm

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
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-26

Fall

HOW
Ziel
verify cross-spawn in pkg:npm/cross-spawn@7.0.6
Pakete
Symbole
  • cross-spawn
Erstellt
2026-08-26T10:41:56Z

Contract

  1. crossSpawn.sync executes command synchronously and returns status 0 with valid pid
  2. crossSpawn.sync decodes stdout and stderr as strings when encoding option is provided
  3. crossSpawn.sync passes arguments and custom environment variables to child process
  4. crossSpawn.sync captures non-zero exit code and standard error on failure
  5. crossSpawn.sync reports ENOENT error when binary does not exist
  6. crossSpawn executes command asynchronously and streams stdout
  7. crossSpawn pipes stdin to child process
  8. crossSpawn emits error event with ENOENT for non-existent command

Dateien

  • PROMPT.md
  • csx.json
  • 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 cross-spawn in pkg:npm/cross-spawn@7.0.6
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/cross-spawn@7.0.6
Demonstrate these symbols/APIs:
  - cross-spawn

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:1cc8daf8fd9f26210030a336410d0a881e5ccfbc52d25b7800d5643cc87cb74f","contract":["crossSpawn.sync executes command synchronously and returns status 0 with valid pid","crossSpawn.sync decodes stdout and stderr as strings when encoding option is provided","crossSpawn.sync passes arguments and custom environment variables to child process","crossSpawn.sync captures non-zero exit code and standard error on failure","crossSpawn.sync reports ENOENT error when binary does not exist","crossSpawn executes command asynchronously and streams stdout","crossSpawn pipes stdin to child process","crossSpawn emits error event with ENOENT for non-existent command"],"goal":"verify cross-spawn in pkg:npm/cross-spawn@7.0.6","kind":"HOW","packages":["pkg:npm/cross-spawn@7.0.6"],"schemaVersion":1,"symbols":["cross-spawn"]},"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/cross-spawn@7.0.6"],"schemaVersion":1,"subject":"pkg:npm/cross-spawn@7.0.6","symbols":["cross-spawn"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "cross-spawn-verification",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "cross-spawn-verification",
      "version": "1.0.0",
      "dependencies": {
        "cross-spawn": "7.0.6"
      }
    },
    "node_modules/cross-spawn": {
      "version": "7.0.6",
      "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
      "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
      "license": "MIT",
      "dependencies": {
        "path-key": "^3.1.0",
        "shebang-command": "^2.0.0",
        "which": "^2.0.1"
      },
      "engines": {
        "node": ">= 8"
      }
    },
    "node_modules/isexe": {
      "version": "2.0.0",
      "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
      "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",
      "license": "ISC"
    },
    "node_modules/path-key": {
      "version": "3.1.1",
      "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
      "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",
      "license": "MIT",
      "engines": {
        "node": ">=8"
      }
    },
    "node_modules/shebang-command": {
      "version": "2.0.0",
      "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
      "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
      "license": "MIT",
      "dependencies": {
        "shebang-regex": "^3.0.0"
      },
      "engines": {
        "node": ">=8"
      }
    },
    "node_modules/shebang-regex": {
      "version": "3.0.0",
      "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",
      "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
      "license": "MIT",
      "engines": {
        "node": ">=8"
      }
    },
    "node_modules/which": {
      "version": "2.0.2",
      "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
      "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
      "license": "ISC",
      "dependencies": {
        "isexe": "^2.0.0"
      },
      "bin": {
        "node-which": "bin/node-which"
      },
      "engines": {
        "node": ">= 8"
      }
    }
  }
}
package.json
{
  "name": "cross-spawn-verification",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "dependencies": {
    "cross-spawn": "7.0.6"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify cross-spawn in pkg:npm/cross-spawn@7.0.6",
  "kind": "HOW",
  "packages": [
    "pkg:npm/cross-spawn@7.0.6"
  ],
  "symbols": [
    "cross-spawn"
  ]
}
test/contract.mjs
import assert from 'node:assert';
import spawn from 'cross-spawn';

// 1. crossSpawn.sync executes command synchronously and returns status 0 with valid pid
const resultSync = spawn.sync('node', ['-e', 'console.log("hello cross-spawn")']);
assert.strictEqual(resultSync.status, 0);
assert.strictEqual(resultSync.signal, null);
assert.strictEqual(resultSync.error, null);
assert.ok(typeof resultSync.pid === 'number' && resultSync.pid > 0);
assert.ok(resultSync.stdout.toString().includes('hello cross-spawn'));

// 2. crossSpawn.sync decodes stdout and stderr as strings when encoding option is provided
const resultEncoded = spawn.sync('node', ['-e', 'console.log("encoded-output")'], {
  encoding: 'utf8'
});
assert.strictEqual(resultEncoded.status, 0);
assert.strictEqual(resultEncoded.stdout.trim(), 'encoded-output');
assert.strictEqual(resultEncoded.stderr, '');

// 3. crossSpawn.sync passes arguments and custom environment variables to child process
const resultEnv = spawn.sync('node', ['-e', 'console.log(process.env.TEST_VAR, process.argv[1])', 'arg1'], {
  encoding: 'utf8',
  env: { ...process.env, TEST_VAR: 'custom_value' }
});
assert.strictEqual(resultEnv.status, 0);
assert.ok(resultEnv.stdout.includes('custom_value arg1'));

// 4. crossSpawn.sync captures non-zero exit code and standard error on failure
const resultFail = spawn.sync('node', ['-e', 'console.error("error occurred"); process.exit(42)'], {
  encoding: 'utf8'
});
assert.strictEqual(resultFail.status, 42);
assert.ok(resultFail.stderr.includes('error occurred'));

// 5. crossSpawn.sync reports ENOENT error when binary does not exist
const resultEnoent = spawn.sync('non_existent_command_123456_xyz', ['--test']);
assert.ok(resultEnoent.error !== null && resultEnoent.error !== undefined);
assert.strictEqual(resultEnoent.error.code, 'ENOENT');

// 6. crossSpawn executes command asynchronously and streams stdout
const child = spawn('node', ['-e', 'console.log("async output")']);
let stdoutData = '';
child.stdout.on('data', (chunk) => {
  stdoutData += chunk.toString();
});

const [exitCode] = await new Promise((resolve) => {
  child.on('close', (code, signal) => {
    resolve([code, signal]);
  });
});
assert.strictEqual(exitCode, 0);
assert.ok(stdoutData.includes('async output'));

// 7. crossSpawn pipes stdin to child process
const childStdin = spawn('node', ['-e', 'process.stdin.pipe(process.stdout)']);
let pipedOutput = '';
childStdin.stdout.on('data', (chunk) => {
  pipedOutput += chunk.toString();
});
childStdin.stdin.write('piped-input-data\n');
childStdin.stdin.end();

const [stdinExitCode] = await new Promise((resolve) => {
  childStdin.on('close', (code) => {
    resolve([code]);
  });
});
assert.strictEqual(stdinExitCode, 0);
assert.strictEqual(pipedOutput.trim(), 'piped-input-data');

// 8. crossSpawn emits error event with ENOENT for non-existent command
const childMissing = spawn('non_existent_binary_xyz_123456', ['--arg']);
const missingError = await new Promise((resolve) => {
  childMissing.on('error', (err) => {
    resolve(err);
  });
});
assert.ok(missingError !== null);
assert.strictEqual(missingError.code, 'ENOENT');

console.log('Contract passed');

Ursprungs-Seeder

anonym