샘플
resolve-cwd 3.0.0: resolve module path from current working directory or return undefined silently
검증된 샘플 — npm resolve-cwd 3.0.0: resolve module path from current working directory or return undefined silently. node 22 · linux alpine/x64 · docker에서…
sha256:022d81be2eae7cb4b1e1a75dd3f647a6db0aab22160d2d13daf5f1a846e8fda0
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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-27 |
케이스
HOW- 목표
- resolve module path from current working directory or return undefined silently
- 심벌
-
- resolveCwd
- resolveCwd.silent
- 환경
- node 22.23.2
- 생성일
- 2026-08-27T21:37:48Z
컨트랙트
- assert resolveCwd resolves existing module path relative to current working directory
- assert resolveCwd resolves installed package module from current working directory
- assert resolveCwd throws MODULE_NOT_FOUND error when target module does not exist
- assert resolveCwd.silent returns absolute path for existing module relative to current working directory
- assert resolveCwd.silent returns undefined without throwing for non-existent module
파일
- PROMPT.md
- csx.json
- index.js
- 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: resolve module path from current working directory or return undefined silently
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/resolve-cwd@3.0.0
Demonstrate these symbols/APIs:
- resolveCwd
- resolveCwd.silent
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:de79658d54cf23daa19731dfd35f04b4cb14452b3e1f11ef3925758ce4fcbdf5","contract":["assert resolveCwd resolves existing module path relative to current working directory","assert resolveCwd resolves installed package module from current working directory","assert resolveCwd throws MODULE_NOT_FOUND error when target module does not exist","assert resolveCwd.silent returns absolute path for existing module relative to current working directory","assert resolveCwd.silent returns undefined without throwing for non-existent module"],"goal":"resolve module path from current working directory or return undefined silently","kind":"HOW","packages":["pkg:npm/resolve-cwd@3.0.0"],"schemaVersion":1,"symbols":["resolveCwd","resolveCwd.silent"]},"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/resolve-cwd@3.0.0"],"schemaVersion":1,"subject":"pkg:npm/resolve-cwd@3.0.0","symbols":["resolveCwd","resolveCwd.silent"],"verifierAdapter":"node-typescript@1"}
const resolveCwd = require('resolve-cwd');
/**
* Resolves the path of a module from the current working directory.
* Throws MODULE_NOT_FOUND error if the module cannot be resolved.
*
* @param {string} moduleId - The module identifier or relative path to resolve.
* @returns {string} The resolved absolute file path.
*/
function resolveFromCurrentDir(moduleId) {
return resolveCwd(moduleId);
}
/**
* Resolves the path of a module from the current working directory silently.
* Returns undefined instead of throwing if the module cannot be resolved.
*
* @param {string} moduleId - The module identifier or relative path to resolve.
* @returns {string | undefined} The resolved absolute file path or undefined.
*/
function resolveFromCurrentDirSilent(moduleId) {
return resolveCwd.silent(moduleId);
}
module.exports = {
resolveFromCurrentDir,
resolveFromCurrentDirSilent,
resolveCwd,
};
{
"name": "sample-resolve-cwd",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-resolve-cwd",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"resolve-cwd": "3.0.0"
}
},
"node_modules/resolve-cwd": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz",
"integrity": "sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==",
"license": "MIT",
"dependencies": {
"resolve-from": "^5.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/resolve-from": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz",
"integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==",
"license": "MIT",
"engines": {
"node": ">=8"
}
}
}
}
{
"name": "sample-resolve-cwd",
"version": "1.0.0",
"description": "Clean-room sample demonstrating resolve-cwd module resolution from current working directory",
"main": "index.js",
"license": "MIT-0",
"dependencies": {
"resolve-cwd": "3.0.0"
}
}
{
"schemaVersion": 1,
"goal": "resolve module path from current working directory or return undefined silently",
"kind": "HOW",
"packages": [
"pkg:npm/resolve-cwd@3.0.0"
],
"symbols": [
"resolveCwd",
"resolveCwd.silent"
]
}
import assert from 'node:assert';
import path from 'node:path';
import resolveCwd from 'resolve-cwd';
import { resolveFromCurrentDir, resolveFromCurrentDirSilent } from '../index.js';
// 1. Verify resolveCwd resolves an existing relative file from the current working directory
const expectedPackageJsonPath = path.resolve(process.cwd(), 'package.json');
const resolvedPkg = resolveCwd('./package.json');
assert.strictEqual(resolvedPkg, expectedPackageJsonPath, 'resolveCwd must resolve relative package.json to its absolute path');
const helperResolvedPkg = resolveFromCurrentDir('./package.json');
assert.strictEqual(helperResolvedPkg, expectedPackageJsonPath, 'resolveFromCurrentDir must resolve relative package.json to its absolute path');
// 2. Verify resolveCwd resolves an installed package from cwd
const resolvedPackage = resolveCwd('resolve-cwd');
assert.strictEqual(typeof resolvedPackage, 'string', 'resolveCwd must resolve installed package to a string path');
assert.ok(resolvedPackage.includes('resolve-cwd'), 'Resolved path must contain package name');
// 3. Verify resolveCwd throws MODULE_NOT_FOUND error when the module does not exist
assert.throws(
() => {
resolveCwd('./non-existent-module-xyz.js');
},
(err) => {
assert.strictEqual(err.code, 'MODULE_NOT_FOUND', 'resolveCwd must throw error with code MODULE_NOT_FOUND for missing module');
return true;
},
'resolveCwd must throw MODULE_NOT_FOUND for non-existent module'
);
assert.throws(
() => {
resolveFromCurrentDir('./non-existent-module-xyz.js');
},
(err) => {
assert.strictEqual(err.code, 'MODULE_NOT_FOUND', 'resolveFromCurrentDir must throw error with code MODULE_NOT_FOUND for missing module');
return true;
},
'resolveFromCurrentDir must throw MODULE_NOT_FOUND for non-existent module'
);
// 4. Verify resolveCwd.silent returns absolute path for an existing relative file
const silentResolvedPkg = resolveCwd.silent('./package.json');
assert.strictEqual(silentResolvedPkg, expectedPackageJsonPath, 'resolveCwd.silent must resolve existing relative module');
const helperSilentResolvedPkg = resolveFromCurrentDirSilent('./package.json');
assert.strictEqual(helperSilentResolvedPkg, expectedPackageJsonPath, 'resolveFromCurrentDirSilent must resolve existing relative module');
// 5. Verify resolveCwd.silent returns undefined without throwing for non-existent module
const silentMissing = resolveCwd.silent('./non-existent-module-xyz.js');
assert.strictEqual(silentMissing, undefined, 'resolveCwd.silent must return undefined for non-existent module');
const helperSilentMissing = resolveFromCurrentDirSilent('./non-existent-module-xyz.js');
assert.strictEqual(helperSilentMissing, undefined, 'resolveFromCurrentDirSilent must return undefined for non-existent module');
console.log('All contract assertions passed.');
오리진 시더
익명