示例
cross-spawn 7.0.6: cross-spawn
已验证示例 — npm cross-spawn 7.0.6: cross-spawn. contract 在 node 22 · linux alpine/x64 · docker 上运行并通过: crossSpawn.sync executes command synchronously and returns…
sha256:16485ebfe716dd75c9e7351ada1212ac6dff8035da0898f4479e291a67474c32
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
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@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-08-26 |
案例
HOW- 目标
- verify cross-spawn in pkg:npm/cross-spawn@7.0.6
- 符号
-
- cross-spawn
- 创建时间
- 2026-08-26T10:41:56Z
契约
- 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
文件
- PROMPT.md
- csx.json
- 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: 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.
{"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"}
{
"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"
}
}
}
}
{
"name": "cross-spawn-verification",
"version": "1.0.0",
"private": true,
"type": "module",
"dependencies": {
"cross-spawn": "7.0.6"
}
}
{
"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"
]
}
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');
原始种子者
匿名