샘플
tinyexec 1.3.0: NonZeroExitError
검증된 샘플 — npm tinyexec 1.3.0: NonZeroExitError. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: NonZeroExitError is an Error subclass representing…
sha256:72b59841986713e9c5eff359f36e9ec3254a95ff24d73fc4c29a157e31bb0a71
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
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.NonZeroExitError in pkg:npm/tinyexec@1.3.0
- 패키지
- 심벌
-
- tinyexec.NonZeroExitError
- 환경
- node 22.23.2
- 생성일
- 2026-09-06T14:42:53Z
컨트랙트
- NonZeroExitError is an Error subclass representing command exit failure
- NonZeroExitError constructor populates exitCode, signalCode, output, and non-enumerable result
- NonZeroExitError formats error message with command and arguments on non-zero exit
- NonZeroExitError formats error message with termination signal when process is killed
- x throws NonZeroExitError containing stdout, stderr, and exitCode when throwOnError is enabled
- xSync throws NonZeroExitError containing output and exitCode when throwOnError is enabled
- ExecProcess async iteration throws NonZeroExitError when process terminates with non-zero exit code
- NonZeroExitError signalCode captures process signal when process is killed with throwOnError enabled
파일
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- 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 tinyexec.NonZeroExitError 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.NonZeroExitError
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:c4c1b270cab4700de29b180fb76b7423b339c1f5d220f6cec080021cf61a815a","contract":["NonZeroExitError is an Error subclass representing command exit failure","NonZeroExitError constructor populates exitCode, signalCode, output, and non-enumerable result","NonZeroExitError formats error message with command and arguments on non-zero exit","NonZeroExitError formats error message with termination signal when process is killed","x throws NonZeroExitError containing stdout, stderr, and exitCode when throwOnError is enabled","xSync throws NonZeroExitError containing output and exitCode when throwOnError is enabled","ExecProcess async iteration throws NonZeroExitError when process terminates with non-zero exit code","NonZeroExitError signalCode captures process signal when process is killed with throwOnError enabled"],"goal":"verify tinyexec.NonZeroExitError in pkg:npm/tinyexec@1.3.0","kind":"HOW","packages":["pkg:npm/tinyexec@1.3.0"],"schemaVersion":1,"symbols":["tinyexec.NonZeroExitError"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","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.NonZeroExitError"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-tinyexec-nonzeroexiterror",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-tinyexec-nonzeroexiterror",
"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-nonzeroexiterror",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification of tinyexec.NonZeroExitError in pkg:npm/tinyexec@1.3.0",
"type": "module",
"main": "src/index.js",
"license": "MIT-0",
"dependencies": {
"tinyexec": "1.3.0"
}
}
{
"schemaVersion": 1,
"goal": "verify tinyexec.NonZeroExitError in pkg:npm/tinyexec@1.3.0",
"kind": "HOW",
"packages": [
"pkg:npm/tinyexec@1.3.0"
],
"symbols": [
"tinyexec.NonZeroExitError"
]
}
import { NonZeroExitError, x, xSync, ExecProcess } from 'tinyexec';
/**
* Creates a NonZeroExitError instance.
* @param {import('tinyexec').CommonOutputApi} result - Execution output API instance
* @param {import('tinyexec').Output} [output] - Output object with stdout, stderr, exitCode
* @param {string} [command] - Command name
* @param {string[]} [args] - Command arguments
* @returns {NonZeroExitError}
*/
export function createNonZeroExitError(result, output, command, args) {
return new NonZeroExitError(result, output, command, args);
}
/**
* Executes a command asynchronously with throwOnError enabled.
* @param {string} command - Command to run
* @param {string[]} [args] - Arguments
* @param {object} [options] - Options
* @returns {import('tinyexec').Result}
*/
export function runWithThrowOnError(command, args, options) {
return x(command, args, { ...options, throwOnError: true });
}
/**
* Executes a command synchronously with throwOnError enabled.
* @param {string} command - Command to run
* @param {string[]} [args] - Arguments
* @param {object} [options] - Options
* @returns {import('tinyexec').SyncResult}
*/
export function runSyncWithThrowOnError(command, args, options) {
return xSync(command, args, { ...options, throwOnError: true });
}
export { NonZeroExitError, x, xSync, ExecProcess };
import assert from 'node:assert/strict';
import {
NonZeroExitError,
x,
xSync,
ExecProcess,
createNonZeroExitError,
runWithThrowOnError,
runSyncWithThrowOnError
} from '../src/index.js';
// 1. NonZeroExitError is an Error subclass representing command exit failure
assert.equal(typeof NonZeroExitError, 'function', 'NonZeroExitError must be a constructor function');
assert.ok(NonZeroExitError.prototype instanceof Error, 'NonZeroExitError must extend Error');
assert.equal(typeof createNonZeroExitError, 'function');
assert.equal(typeof runWithThrowOnError, 'function');
assert.equal(typeof runSyncWithThrowOnError, 'function');
// 2. NonZeroExitError constructor populates exitCode, signalCode, output, and non-enumerable result
{
const mockResult = {
exitCode: 42,
signalCode: null,
pid: 1234,
killed: false
};
const mockOutput = {
stdout: 'mock stdout',
stderr: 'mock stderr',
exitCode: 42
};
const err = createNonZeroExitError(mockResult, mockOutput, 'my-cmd', ['--flag', 'value with spaces']);
assert.ok(err instanceof Error);
assert.ok(err instanceof NonZeroExitError);
assert.equal(err.exitCode, 42);
assert.equal(err.signalCode, null);
assert.deepEqual(err.output, mockOutput);
assert.equal(err.result, mockResult);
assert.equal(Object.prototype.propertyIsEnumerable.call(err, 'result'), false);
}
// 3. NonZeroExitError formats error message with command and arguments on non-zero exit
{
const mockResult = {
exitCode: 2,
signalCode: null,
pid: 2222,
killed: false
};
const errWithArgs = createNonZeroExitError(mockResult, undefined, 'test-bin', ['arg1', 'arg with space']);
assert.equal(errWithArgs.message, 'The command `test-bin arg1 "arg with space"` exited with a non-zero status (2)');
const errNoCommand = createNonZeroExitError(mockResult);
assert.equal(errNoCommand.message, 'The process exited with a non-zero status (2)');
}
// 4. NonZeroExitError formats error message with termination signal when process is killed
{
const mockResult = {
exitCode: null,
signalCode: 'SIGKILL',
pid: 3333,
killed: true
};
const err = createNonZeroExitError(mockResult, undefined, 'long-runner');
assert.equal(err.signalCode, 'SIGKILL');
assert.equal(err.exitCode, 1);
assert.equal(err.message, 'The command `long-runner` was killed by the signal SIGKILL');
}
// 5. x throws NonZeroExitError containing stdout, stderr, and exitCode when throwOnError is enabled
{
await assert.rejects(
async () => {
await runWithThrowOnError('node', [
'-e',
'process.stdout.write("standard message\\n"); process.stderr.write("error message\\n"); process.exit(7);'
]);
},
(err) => {
assert.ok(err instanceof NonZeroExitError, 'Expected instance of NonZeroExitError');
assert.equal(err.exitCode, 7);
assert.equal(err.signalCode, null);
assert.equal(err.output?.stdout, 'standard message\n');
assert.equal(err.output?.stderr, 'error message\n');
assert.equal(err.output?.exitCode, 7);
return true;
}
);
}
// 6. xSync throws NonZeroExitError containing output and exitCode when throwOnError is enabled
{
assert.throws(
() => {
runSyncWithThrowOnError('node', [
'-e',
'process.stdout.write("sync stdout\\n"); process.stderr.write("sync stderr\\n"); process.exit(9);'
]);
},
(err) => {
assert.ok(err instanceof NonZeroExitError, 'Expected instance of NonZeroExitError');
assert.equal(err.exitCode, 9);
assert.equal(err.signalCode, null);
assert.equal(err.output?.stdout, 'sync stdout\n');
assert.equal(err.output?.stderr, 'sync stderr\n');
assert.equal(err.output?.exitCode, 9);
return true;
}
);
}
// 7. ExecProcess async iteration throws NonZeroExitError when process terminates with non-zero exit code
{
const proc = new ExecProcess(
'node',
['-e', 'console.log("line-one"); console.log("line-two"); process.exit(11);'],
{ throwOnError: true }
);
proc.spawn();
const receivedLines = [];
await assert.rejects(
async () => {
for await (const line of proc) {
receivedLines.push(line.trim());
}
},
(err) => {
assert.ok(err instanceof NonZeroExitError, 'Expected instance of NonZeroExitError');
assert.equal(err.exitCode, 11);
return true;
}
);
assert.deepEqual(receivedLines, ['line-one', 'line-two']);
}
// 8. NonZeroExitError signalCode captures process signal when process is killed with throwOnError enabled
{
await assert.rejects(
async () => {
const proc = runWithThrowOnError('node', ['-e', 'setInterval(() => {}, 1000);']);
await new Promise((resolve) => setTimeout(resolve, 50));
proc.kill('SIGTERM');
await proc;
},
(err) => {
assert.ok(err instanceof NonZeroExitError, 'Expected instance of NonZeroExitError');
assert.equal(err.signalCode, 'SIGTERM');
assert.ok(err.message.includes('was killed by the signal SIGTERM'));
return true;
}
);
}
console.log('All contract assertions passed.');
오리진 시더
익명