Пример
tinyexec 1.3.0: ExecProcess
Проверенный пример — npm tinyexec 1.3.0: ExecProcess. Контракт выполнен на node 22 · linux debian/x64 · docker и пройден: ExecProcess creates an unspawned…
sha256:340fb5f885cb227e5ea373efafe2c61a33a337750ab8e57ccfe3096986485aab
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
MIT-0
Свидетельства выполнения
Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.
- Основа свидетельства
- Подписанный контракт пройден
- Квитанции проверки
- 1
- Ключи подписи, собравшие его
- 1
Заявленная среда
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Среды запусков проверки
| Окружение | Контракт | Этапы | Запуск |
|---|---|---|---|
| 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-06 |
Кейс
HOW- Цель
- verify tinyexec.ExecProcess in pkg:npm/tinyexec@1.3.0
- Пакеты
- Символы
-
- tinyexec.ExecProcess
- Окружение
- node 22.23.2
- Создан
- 2026-09-06T12:35:40Z
Контракт
- ExecProcess creates an unspawned process representation that starts execution upon spawn
- ExecProcess exposes child process properties including exitCode and signalCode
- ExecProcess is thenable and resolves to stdout, stderr, and exitCode upon completion
- ExecProcess supports passing stdin input string to the spawned process
- ExecProcess supports streaming and async iteration over output lines
- ExecProcess pipe method chains output to another process
- ExecProcess throws NonZeroExitError on non-zero exit code when throwOnError is enabled
- ExecProcess aborts execution and updates aborted flag when AbortSignal triggers
- ExecProcess kill method terminates the running process
Файлы
- PROMPT.md
- csx.json
- index.cjs
- package-lock.json
- package.json
- spec.json
- test/contract.cjs
Исходный код
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 tinyexec.ExecProcess in pkg:npm/tinyexec@1.3.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/tinyexec@1.3.0
Demonstrate these symbols/APIs:
- tinyexec.ExecProcess
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
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:1ba6208fce34a18d783dc76f066a80ece7b5a7f7adb41ea8d507db9e036abe1b","constraints":{"executionContext":"node"},"contract":["ExecProcess creates an unspawned process representation that starts execution upon spawn","ExecProcess exposes child process properties including exitCode and signalCode","ExecProcess is thenable and resolves to stdout, stderr, and exitCode upon completion","ExecProcess supports passing stdin input string to the spawned process","ExecProcess supports streaming and async iteration over output lines","ExecProcess pipe method chains output to another process","ExecProcess throws NonZeroExitError on non-zero exit code when throwOnError is enabled","ExecProcess aborts execution and updates aborted flag when AbortSignal triggers","ExecProcess kill method terminates the running process"],"goal":"verify tinyexec.ExecProcess in pkg:npm/tinyexec@1.3.0","kind":"HOW","packages":["pkg:npm/tinyexec@1.3.0"],"schemaVersion":1,"symbols":["tinyexec.ExecProcess"]},"contractCommand":["node","test/contract.cjs"],"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/tinyexec@1.3.0"],"schemaVersion":1,"subject":"pkg:npm/tinyexec@1.3.0","symbols":["tinyexec.ExecProcess"],"verifierAdapter":"node-typescript@1"}
'use strict';
const { ExecProcess, NonZeroExitError } = require('tinyexec');
/**
* Creates and spawns an ExecProcess instance.
* @param {string} command - Command to run
* @param {string[]} [args] - Arguments array
* @param {object} [options] - Options
* @returns {ExecProcess}
*/
function createProcess(command, args, options) {
const proc = new ExecProcess(command, args, options);
proc.spawn();
return proc;
}
/**
* Creates an unspawned ExecProcess instance.
* @param {string} command - Command to run
* @param {string[]} [args] - Arguments array
* @param {object} [options] - Options
* @returns {ExecProcess}
*/
function buildProcess(command, args, options) {
return new ExecProcess(command, args, options);
}
module.exports = {
ExecProcess,
NonZeroExitError,
createProcess,
buildProcess
};
{
"name": "sample-tinyexec-execprocess",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-tinyexec-execprocess",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"tinyexec": "1.3.0"
}
},
"node_modules/tinyexec": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.3.0.tgz",
"integrity": "sha512-QKAl9m8gWWGHV8jZcPeym6j+XULi6tOf1mT83WYJ4Lk2ytW/uwAWkrP0uFsdoYMdueVJ0qs26wZ+23xeB4ibNQ==",
"license": "MIT",
"engines": {
"node": ">=18"
}
}
}
}
{
"name": "sample-tinyexec-execprocess",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification of tinyexec.ExecProcess in pkg:npm/tinyexec@1.3.0",
"main": "index.cjs",
"dependencies": {
"tinyexec": "1.3.0"
}
}
{
"schemaVersion": 1,
"goal": "verify tinyexec.ExecProcess in pkg:npm/tinyexec@1.3.0",
"kind": "HOW",
"packages": [
"pkg:npm/tinyexec@1.3.0"
],
"symbols": [
"tinyexec.ExecProcess"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
'use strict';
const assert = require('node:assert/strict');
const {
ExecProcess,
NonZeroExitError,
createProcess,
buildProcess
} = require('../index.cjs');
async function main() {
// 1. ExecProcess is exported as a class constructor
assert.equal(typeof ExecProcess, 'function', 'ExecProcess must be a constructor');
assert.equal(typeof createProcess, 'function', 'createProcess helper must be a function');
assert.equal(typeof buildProcess, 'function', 'buildProcess helper must be a function');
// 2. ExecProcess creates an unspawned process representation that starts execution upon spawn
{
const proc = buildProcess('node', ['-e', 'console.log("unspawned-to-spawned")']);
assert.equal(proc.process, undefined, 'process must be undefined before spawn');
assert.equal(proc.pid, undefined, 'pid must be undefined before spawn');
proc.spawn();
assert.ok(proc.process, 'process must be defined after spawn');
assert.equal(typeof proc.pid, 'number', 'pid must be a number after spawn');
const result = await proc;
assert.equal(result.exitCode, 0);
assert.equal(result.stdout.trim(), 'unspawned-to-spawned');
}
// 3. ExecProcess exposes child process properties including exitCode and signalCode
{
const proc = createProcess('node', ['-e', 'process.exit(4)']);
const result = await proc;
assert.equal(result.exitCode, 4);
assert.equal(proc.exitCode, 4);
assert.equal(proc.signalCode, null);
}
// 4. ExecProcess is thenable and resolves to stdout, stderr, and exitCode upon completion
{
const proc = createProcess('node', [
'-e',
'console.log("contract stdout payload"); console.error("contract stderr payload");'
]);
const result = await proc;
assert.equal(result.exitCode, 0);
assert.equal(result.stdout.trim(), 'contract stdout payload');
assert.equal(result.stderr.trim(), 'contract stderr payload');
}
// 5. ExecProcess supports passing stdin input string to the spawned process
{
const proc = createProcess('node', ['-e', 'process.stdin.pipe(process.stdout)'], {
stdin: 'execprocess-stdin-content'
});
const result = await proc;
assert.equal(result.exitCode, 0);
assert.equal(result.stdout.trim(), 'execprocess-stdin-content');
}
// 6. ExecProcess supports streaming and async iteration over output lines
{
const proc = createProcess('node', ['-e', 'console.log("line-alpha"); console.log("line-beta");']);
const lines = [];
for await (const line of proc) {
lines.push(line.trim());
}
assert.deepEqual(lines, ['line-alpha', 'line-beta']);
}
// 7. ExecProcess pipe method chains output to another process
{
const source = createProcess('node', ['-e', 'console.log("pipe-source-text")']);
const piped = source.pipe('node', [
'-e',
'let buf = ""; process.stdin.on("data", c => buf += c); process.stdin.on("end", () => console.log(buf.trim().toUpperCase()));'
]);
const result = await piped;
assert.equal(result.exitCode, 0);
assert.equal(result.stdout.trim(), 'PIPE-SOURCE-TEXT');
}
// 8. ExecProcess throws NonZeroExitError on non-zero exit code when throwOnError is enabled
{
await assert.rejects(
async () => {
const proc = createProcess('node', ['-e', 'process.stderr.write("nonzero failure message"); process.exit(8);'], {
throwOnError: true
});
await proc;
},
(err) => {
assert(err instanceof NonZeroExitError, 'Error must be an instance of NonZeroExitError');
assert.equal(err.exitCode, 8);
assert.equal(err.output?.stderr, 'nonzero failure message');
return true;
}
);
}
// 9. ExecProcess aborts execution and updates aborted flag when AbortSignal triggers
{
const controller = new AbortController();
const proc = createProcess('node', ['-e', 'setInterval(() => {}, 1000);'], {
signal: controller.signal
});
await new Promise((resolve) => setTimeout(resolve, 50));
controller.abort();
await proc;
assert.equal(proc.aborted, true);
assert.equal(proc.killed, true);
}
// 10. ExecProcess kill method terminates the running process
{
const proc = createProcess('node', ['-e', 'setInterval(() => {}, 1000);']);
await new Promise((resolve) => setTimeout(resolve, 50));
const killed = proc.kill('SIGTERM');
assert.equal(killed, true);
await proc;
assert.equal(proc.killed, true);
}
console.log('Contract assertions passed.');
}
main().catch((err) => {
console.error(err);
process.exit(1);
});
Исходный сидер
аноним