CodeSampleX

샘플

npm-run-path 4.0.1: default

검증된 샘플 — npm npm-run-path 4.0.1: default. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: npmRunPath.default is a callable function identical to…

sha256:2cf74171255d41f94d190e156e4a3c65f18085f1d788bbc58e4eb38f8e84ef1b

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. 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 npm-run-path.default in pkg:npm/npm-run-path@4.0.1
패키지
심벌
  • npm-run-path.default
환경
node 22.23.2
생성일
2026-09-06T16:03:15Z

컨트랙트

  1. npmRunPath.default is a callable function identical to the main export
  2. npmRunPath.default returns a string containing local node_modules/.bin directories
  3. npmRunPath.default with custom cwd and path prepends parent node_modules/.bin directories to custom path
  4. npmRunPath.default.env returns copy of environment with augmented PATH key
  5. npmRunPath.default.env with custom env object augments custom PATH without mutating original input

파일

  • PROMPT.md
  • csx.json
  • index.js
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.mjs

소스 아티팩트 내려받기 (tar.gz)

소스

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 npm-run-path.default in pkg:npm/npm-run-path@4.0.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/npm-run-path@4.0.1
Demonstrate these symbols/APIs:
  - npm-run-path.default
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.
csx.json
{"case":{"caseId":"case:sha256:735f5769c3f05563b12b2299b72e7a68c2e153010792da68c857d7ed7470a12f","constraints":{"executionContext":"node"},"contract":["npmRunPath.default is a callable function identical to the main export","npmRunPath.default returns a string containing local node_modules/.bin directories","npmRunPath.default with custom cwd and path prepends parent node_modules/.bin directories to custom path","npmRunPath.default.env returns copy of environment with augmented PATH key","npmRunPath.default.env with custom env object augments custom PATH without mutating original input"],"goal":"verify npm-run-path.default in pkg:npm/npm-run-path@4.0.1","kind":"HOW","packages":["pkg:npm/npm-run-path@4.0.1"],"schemaVersion":1,"symbols":["npm-run-path.default"]},"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/npm-run-path@4.0.1"],"schemaVersion":1,"subject":"pkg:npm/npm-run-path@4.0.1","symbols":["npm-run-path.default"],"verifierAdapter":"node-typescript@1"}
index.js
const npmRunPath = require('npm-run-path');

function getAugmentedPathWithDefault(options) {
  return npmRunPath.default(options);
}

function getAugmentedEnvWithDefault(options) {
  return npmRunPath.default.env(options);
}

module.exports = {
  npmRunPath,
  getAugmentedPathWithDefault,
  getAugmentedEnvWithDefault,
};
package-lock.json
{
  "name": "sample-npm-run-path-default",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-npm-run-path-default",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "npm-run-path": "4.0.1"
      }
    },
    "node_modules/npm-run-path": {
      "version": "4.0.1",
      "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz",
      "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==",
      "license": "MIT",
      "dependencies": {
        "path-key": "^3.0.0"
      },
      "engines": {
        "node": ">=8"
      }
    },
    "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"
      }
    }
  }
}
package.json
{
  "name": "sample-npm-run-path-default",
  "version": "1.0.0",
  "description": "Verify npm-run-path default export and default.env in pkg:npm/npm-run-path@4.0.1",
  "main": "index.js",
  "license": "MIT-0",
  "dependencies": {
    "npm-run-path": "4.0.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify npm-run-path.default in pkg:npm/npm-run-path@4.0.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/npm-run-path@4.0.1"
  ],
  "symbols": [
    "npm-run-path.default"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
test/contract.mjs
import assert from 'node:assert';
import path from 'node:path';
import npmRunPath from 'npm-run-path';
import {
  getAugmentedPathWithDefault,
  getAugmentedEnvWithDefault,
} from '../index.js';

// 1. npmRunPath.default is a callable function identical to the main export
assert.strictEqual(typeof npmRunPath, 'function', 'npmRunPath must be a function');
assert.strictEqual(typeof npmRunPath.default, 'function', 'npmRunPath.default must be a function');
assert.strictEqual(npmRunPath.default, npmRunPath, 'npmRunPath.default must refer to the same function for CJS/ESM interop');

// 2. npmRunPath.default returns a string containing local node_modules/.bin directories
const defaultPath = npmRunPath.default();
assert.strictEqual(typeof defaultPath, 'string', 'default npmRunPath.default() must return a string');
assert(defaultPath.includes('node_modules' + path.sep + '.bin'), 'default path must contain node_modules/.bin');

const helperPath = getAugmentedPathWithDefault();
assert.strictEqual(typeof helperPath, 'string', 'helper path must return a string');
assert(helperPath.includes('node_modules' + path.sep + '.bin'), 'helper path must contain node_modules/.bin');

// 3. npmRunPath.default with custom cwd and path prepends parent node_modules/.bin directories to custom path
const fakeCwd = path.resolve('fake-project', 'sub-dir');
const fakeExecPath = path.resolve('fake-bin', 'node');
const customPath = npmRunPath.default({
  cwd: fakeCwd,
  path: 'fake-custom-bin',
  execPath: fakeExecPath,
});
const pathParts = customPath.split(path.delimiter);
assert(pathParts.includes(path.join(fakeCwd, 'node_modules/.bin')), 'must include cwd node_modules/.bin');
assert(pathParts.includes(path.join(path.dirname(fakeCwd), 'node_modules/.bin')), 'must include parent node_modules/.bin');
assert(pathParts.includes('fake-custom-bin'), 'must retain custom input path');
assert(pathParts.includes(path.dirname(fakeExecPath)), 'must include dirname of custom execPath');

// 4. npmRunPath.default.env returns copy of environment with augmented PATH key
const envResult = npmRunPath.default.env();
assert.strictEqual(typeof envResult, 'object', 'npmRunPath.default.env() must return an object');
assert('PATH' in envResult || 'Path' in envResult, 'augmented environment must have a PATH key');

const helperEnv = getAugmentedEnvWithDefault();
assert.strictEqual(typeof helperEnv, 'object', 'helperEnv must return an object');
assert('PATH' in helperEnv || 'Path' in helperEnv, 'helperEnv must have a PATH key');

// 5. npmRunPath.default.env with custom env object augments custom PATH without mutating original input
const originalEnv = {
  PATH: 'fake-base-bin',
  CUSTOM_VAR: 'csx_test_value',
};
const customEnvCwd = path.resolve('fake-test-app');
const augmentedEnv = npmRunPath.default.env({
  env: originalEnv,
  cwd: customEnvCwd,
  execPath: fakeExecPath,
});
assert.strictEqual(originalEnv.PATH, 'fake-base-bin', 'original env object must not be mutated');
assert.strictEqual(augmentedEnv.CUSTOM_VAR, 'csx_test_value', 'custom environment variables must be preserved');
assert(augmentedEnv.PATH.includes(path.join(customEnvCwd, 'node_modules/.bin')), 'augmented PATH must include node_modules/.bin');
assert(augmentedEnv.PATH.includes('fake-base-bin'), 'augmented PATH must include original base path');

console.log('Contract tests passed successfully.');

오리진 시더

익명